# Analytics Workers


# queue-processor

The primary analytics worker. Consumes both HIGH_PRIORITY_QUEUE and LOW_PRIORITY_QUEUE, calls platform APIs, and saves stats.

Key functions:

  • processSingleVideo() — fetches and saves stats for one video
  • processBatchVideos() — fetches and saves stats for a batch (5–15 videos)
  • saveVideoData() — inserts into video_statistics, updates videos record

# queue-producer

Scheduled worker that enqueues all tracked videos for nightly refresh.

Cron: 0 0,1 * * * Key function: handleMidnightBatchProcessing()


# dashboard-worker

Triggers the initial stats fetch when a user starts tracking. Also reads analytics data for the dashboard view via Supabase queries.


# blogger-video-consumer

When fetching videos for a tracked blogger account (Instagram/TikTok/YouTube), statistics are saved alongside the video record. For YouTube, stats are separately enqueued to HIGH_PRIORITY_QUEUE as video_batch messages.