mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 17:53:55 +08:00
21 lines
662 B
Ruby
Vendored
21 lines
662 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class AggregateWebHooksEvents < ::Jobs::Scheduled
|
|
every 1.day
|
|
|
|
def execute(args = {})
|
|
date = args[:date].presence || Time.zone.now.to_date
|
|
WebHook
|
|
.joins(
|
|
"LEFT JOIN web_hook_events_daily_aggregates ON web_hooks.id = web_hook_events_daily_aggregates.web_hook_id AND web_hook_events_daily_aggregates.date = '#{date}'",
|
|
)
|
|
.where(active: true)
|
|
.where(web_hook_events_daily_aggregates: { id: nil })
|
|
.distinct
|
|
.each do |web_hook|
|
|
WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: date)
|
|
end
|
|
end
|
|
end
|
|
end
|