Skip to content

Commit

Permalink
removing the useless object_ prefix of the object columns in events, …
Browse files Browse the repository at this point in the history
…this fixed the broken preloads in timeline_events widget too
  • Loading branch information
aajjbb committed Aug 13, 2017
1 parent 19c4ef4 commit 8517657
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions flows/followings.moon
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class FollowingsFlow extends Flow

event = Events\find {
source_user_id: @current_user.id
object_object_id: object.id
object_object_type: Events\object_type_for_object object
object_id: object.id
object_type: Events\object_type_for_object object
event_type: Events.event_types.subscription
}

Expand Down
4 changes: 2 additions & 2 deletions migrations.moon
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ import
{"id", serial}
{"event_type", enum}
{"source_user_id", foreign_key}
{"object_object_id", foreign_key}
{"object_object_type", enum}
{"object_id", foreign_key}
{"object_type", enum}
{"created_at", time}
{"updated_at", time}

Expand Down
4 changes: 2 additions & 2 deletions models/events.moon
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Events extends Model
event_opts = {
event_type: opts.event_type
source_user_id: opts.user.id
object_object_id: opts.object.id
object_object_type: @@object_type_for_object opts.object
object_id: opts.object.id
object_type: @@object_type_for_object opts.object
}

event = safe_insert @, event_opts
Expand Down
6 changes: 3 additions & 3 deletions models/timeline_events.moon
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TimelineEvents extends Model

switch event.event_type
when Events.event_types.update
followers = Followings\select "where object_id = ? and object_type = ?", event.object_object_id, event.object_object_type
followers = Followings\select "where object_id = ? and object_type = ?", event.object_id, event.object_type

Followings\preload_relation followers, "source_user"

Expand All @@ -43,9 +43,9 @@ class TimelineEvents extends Model
event_id: event.id
})

if Events\model_for_object_type(event.object_object_type) == Users
if Events\model_for_object_type(event.object_type) == Users
@@create({
user_id: Users\find(event.object_object_id).id
user_id: Users\find(event.object_id).id
event_id: event.id
})

Expand Down
6 changes: 3 additions & 3 deletions spec/models/events_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe "models.events", ->
user_timeline = user\timeline!

assert.same user.id, event.source_user_id
assert.same followed_user.id, event.object_object_id
assert.same followed_user.id, event.object_id
assert.same event.event_type, Events.event_types.subscription

assert.same, #user_timeline, 1
Expand All @@ -42,7 +42,7 @@ describe "models.events", ->
user_timeline = user\timeline!

assert.same user.id, event.source_user_id
assert.same module.id, event.object_object_id
assert.same module.id, event.object_id
assert.same event.event_type, Events.event_types.subscription

assert.same, #user_timeline, 1
Expand All @@ -60,7 +60,7 @@ describe "models.events", ->
user_timeline = user\timeline!

assert.same user.id, event.source_user_id
assert.same module.id, event.object_object_id
assert.same module.id, event.object_id
assert.same event.event_type, Events.event_types.bookmark

assert.same, #user_timeline, 1
Expand Down
4 changes: 2 additions & 2 deletions widgets/timeline_events.moon
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class TimelineEvents extends require "widgets.base"
a href: @url_for("user_profile", user: user.slug), user\name_for_display!
text message

switch Events\model_for_object_type(row_event.object_object_type)
switch Events\model_for_object_type(row_event.object_type)
when Modules
module = row_event.object
a {
class: "title",
href: @url_for("module", user: user.slug, module: module.name)
}, mod\name_for_display!
}, module\name_for_display!
when Users
usr = row_event.object
a {
Expand Down

0 comments on commit 8517657

Please sign in to comment.