-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(missing-user-stats): missing user stats rows covered via migration #1409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| -- Backfill user_stats for any users missing a stats row | ||
| -- Uses defaults from schema for limits and counters | ||
|
|
||
| INSERT INTO "user_stats" ( | ||
| "id", | ||
| "user_id", | ||
| "current_usage_limit", | ||
| "usage_limit_updated_at", | ||
| "total_manual_executions", | ||
| "total_api_calls", | ||
| "total_webhook_triggers", | ||
| "total_scheduled_executions", | ||
| "total_chat_executions", | ||
| "total_tokens_used", | ||
| "total_cost", | ||
| "current_period_cost", | ||
| "last_period_cost", | ||
| "total_copilot_cost", | ||
| "total_copilot_tokens", | ||
| "total_copilot_calls", | ||
| "last_active", | ||
| "billing_blocked" | ||
| ) | ||
| SELECT | ||
| u."id" AS id, | ||
| u."id" AS user_id, | ||
| NULL::decimal AS current_usage_limit, | ||
| NOW() AS usage_limit_updated_at, | ||
| 0 AS total_manual_executions, | ||
| 0 AS total_api_calls, | ||
| 0 AS total_webhook_triggers, | ||
| 0 AS total_scheduled_executions, | ||
| 0 AS total_chat_executions, | ||
| 0 AS total_tokens_used, | ||
| '0'::decimal AS total_cost, | ||
| '0'::decimal AS current_period_cost, | ||
| '0'::decimal AS last_period_cost, | ||
| '0'::decimal AS total_copilot_cost, | ||
| 0 AS total_copilot_tokens, | ||
| 0 AS total_copilot_calls, | ||
| NOW() AS last_active, | ||
| FALSE AS billing_blocked | ||
| FROM "user" u | ||
| LEFT JOIN "user_stats" s ON s."user_id" = u."id" | ||
| WHERE s."user_id" IS NULL; | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Inconsistent decimal casting - some use '0'::decimal while current_usage_limit uses NULL::decimal. Consider using consistent casting for all decimal fields.