Fix notifications past aggregation query (#3998)

This commit is contained in:
Ben Halpern 2019-09-10 11:27:23 -04:00 committed by GitHub
parent 80e6cf4801
commit 590149fd48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View file

@ -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

View file

@ -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