Class: Jobs::IgnoredUsersSummary

Inherits:
Scheduled show all
Defined in:
app/jobs/scheduled/ignored_users_summary.rb

Instance Method Summary collapse

Methods inherited from Scheduled

#perform

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/jobs/scheduled/ignored_users_summary.rb', line 7

def execute(args)
  params = {
    threshold: SiteSetting.ignored_users_count_message_threshold,
    gap_days: SiteSetting.ignored_users_message_gap_days,
    coalesced_gap_days: SiteSetting.ignored_users_message_gap_days + 1,
  }
  user_ids = DB.query_single(<<~SQL, params)
    SELECT ignored_user_id
    FROM ignored_users
    WHERE COALESCE(summarized_at, CURRENT_TIMESTAMP + ':coalesced_gap_days DAYS'::INTERVAL) - ':gap_days DAYS'::INTERVAL > CURRENT_TIMESTAMP
    GROUP BY ignored_user_id
    HAVING COUNT(ignored_user_id) >= :threshold
  SQL

  User.where(id: user_ids).find_each { |user| notify_user(user) }
end