Fix notifications past aggregation query (#3998)
This commit is contained in:
parent
80e6cf4801
commit
590149fd48
2 changed files with 3 additions and 7 deletions
|
|
@ -26,7 +26,7 @@ class NotificationsController < ApplicationController
|
|||
@user.notifications
|
||||
end
|
||||
|
||||
@notifications = @notifications.without_recently_aggregated_reactions_and_follows.order(notified_at: :desc)
|
||||
@notifications = @notifications.without_past_aggregations.order(notified_at: :desc)
|
||||
|
||||
# if offset based pagination is invoked by the frontend code, we filter out all earlier ones
|
||||
@notifications = @notifications.where("notified_at < ?", notified_at_offset) if notified_at_offset
|
||||
|
|
|
|||
|
|
@ -22,12 +22,8 @@ class Notification < ApplicationRecord
|
|||
where(organization_id: org_id, notifiable_type: "Mention", user_id: nil)
|
||||
}
|
||||
|
||||
scope :with_recently_aggregated_reactions_and_follows, lambda {
|
||||
where("notified_at < ?", 24.hours.ago).
|
||||
where(action: %w[Reaction Follow])
|
||||
}
|
||||
scope :without_recently_aggregated_reactions_and_follows, lambda {
|
||||
where.not(with_recently_aggregated_reactions_and_follows.arel.exists)
|
||||
scope :without_past_aggregations, lambda {
|
||||
where.not("notified_at < ? AND action IN ('Reaction', 'Follow')", 24.hours.ago)
|
||||
}
|
||||
|
||||
class << self
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue