Skip to content

Conversation

@TheMorpheus407
Copy link

Summary

  • Fixed PostgreSQL type casting issues in the active users analytics endpoint
  • Added explicit timestamptz cast for start parameter
  • Added bigint cast for bucket_count parameter
  • Changed interval parameter to use integer concatenation instead of string

Details

The /analytics/active-users endpoint was returning "Internal server error" due to SQL type casting issues in the PostgreSQL query. The fixes ensure proper type coercion:

  1. Start parameter: Now explicitly casts to timestamptz
  2. Bucket count: Now explicitly casts to bigint
  3. Interval: Changed from passing a formatted string to passing bucket_seconds as integer and constructing the interval in SQL

Test plan

  • Endpoint returns 200 OK with admin authentication
  • Returns correct JSON structure with bucket_start and active_users
  • Works with different time ranges (1d, 7d, 30d, 90d)
  • Works with different granularities (1h, 1d, 7d, 30d)
  • Shows actual active user counts from session data
  • Tested via curl with admin token

Example Response

[
  {
    "bucket_start": 1761465600,
    "active_users": 1
  },
  {
    "bucket_start": 1761469200,
    "active_users": 2
  }
]

The endpoint now correctly returns active user statistics bucketed by configurable time ranges and granularities for the admin dashboard.

🤖 Generated with Claude Code

Fixed PostgreSQL type casting issues in the active users analytics endpoint:
- Added explicit timestamptz cast for start parameter
- Added bigint cast for bucket_count parameter
- Changed interval parameter to use integer concatenation instead of string

The endpoint now correctly returns active user statistics bucketed by
configurable time ranges and granularities for the admin dashboard.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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