Use only parquet files for events
This commit is contained in:
25
app/jobs/consolidate_parquet_weekly_job.rb
Normal file
25
app/jobs/consolidate_parquet_weekly_job.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Background job to consolidate completed week into archive
|
||||
# Runs Monday at 00:05 (start of new week)
|
||||
# Merges the previous week's day files into a week archive and deletes day files
|
||||
class ConsolidateParquetWeeklyJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
service = AnalyticsDuckdbService.instance
|
||||
|
||||
# Consolidate the previous week (Monday to Sunday)
|
||||
previous_week_start = 1.week.ago.beginning_of_week
|
||||
|
||||
Rails.logger.info "[Parquet Consolidate] Starting weekly consolidation for week starting #{previous_week_start.strftime('%Y-%m-%d')}"
|
||||
|
||||
service.consolidate_days_to_week(previous_week_start)
|
||||
|
||||
Rails.logger.info "[Parquet Consolidate] Weekly consolidation complete"
|
||||
rescue StandardError => e
|
||||
Rails.logger.error "[Parquet Consolidate] Weekly job failed: #{e.message}"
|
||||
Rails.logger.error e.backtrace.join("\n")
|
||||
raise # Re-raise to mark job as failed in Solid Queue
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user