Skip to content

Add weekly stats cron job with Telegram notifications#3

Open
gianpaj wants to merge 2 commits into
mainfrom
claude/weekly-stats-cron-job-d2gzU
Open

Add weekly stats cron job with Telegram notifications#3
gianpaj wants to merge 2 commits into
mainfrom
claude/weekly-stats-cron-job-d2gzU

Conversation

@gianpaj
Copy link
Copy Markdown
Owner

@gianpaj gianpaj commented May 17, 2026

Summary

This PR adds a scheduled cron job that generates and sends weekly statistics about the waitlist to Telegram every Friday at 5 PM UTC.

Key Changes

  • New API endpoint (api/weekly-stats.ts): Serverless function that:

    • Queries the database for total waitlist count and new signups from the past 7 days
    • Sends formatted statistics to Telegram via webhook
    • Includes Bearer token authentication in production environments
    • Validates required environment variables (TELEGRAM_WEBHOOK_URL, TELEGRAM_CHAT_ID, CRON_SECRET)
  • Updated Vercel configuration (vercel.json):

    • Added cron job schedule to trigger the weekly stats endpoint every Friday at 17:00 UTC (0 17 * * 5)

Implementation Details

  • Uses Drizzle ORM for database queries with SQL execution
  • Parallel database queries for efficiency (total count and 7-day new signups)
  • Telegram message formatted with Markdown for better readability
  • Authorization check skipped in non-production environments for easier local testing
  • Returns JSON response with computed statistics for monitoring/debugging

https://claude.ai/code/session_01EBSzm4mmqrjQYk5KBo5SJg

Runs every Friday at 17:00 UTC. Queries total and new-this-week
waitlist signups via Drizzle/Postgres, then sends a Markdown-formatted
summary to Telegram using TELEGRAM_WEBHOOK_URL and TELEGRAM_CHAT_ID.
Protected by CRON_SECRET bearer token in production.

https://claude.ai/code/session_01EBSzm4mmqrjQYk5KBo5SJg
@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentcaller Ready Ready Preview, Comment May 17, 2026 10:34am

Request Review

db.execute() returns QueryResult which is not array-destructurable.
Switch to db.select() following the same pattern as api/waitlist.ts.

https://claude.ai/code/session_01EBSzm4mmqrjQYk5KBo5SJg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants