-
-
Notifications
You must be signed in to change notification settings - Fork 131
feat(admin): daily history of apps with preview QR enabled #2937
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||
| ALTER TABLE public.global_stats | ||||||
| ADD COLUMN IF NOT EXISTS apps_with_preview bigint NOT NULL DEFAULT 0; | ||||||
|
Comment on lines
+1
to
+2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Prevent false historical values.
Backfill from a source that records historical 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| COMMENT ON COLUMN public.global_stats.apps_with_preview | ||||||
| IS 'Number of apps with preview QR enabled (allow_preview = true) at snapshot day end.'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Fix the SQL comment line length. SQLFluff reports that Line 5 is 90 characters, exceeding the 80-character limit. Shorten or split the comment without changing its meaning. Proposed fix- IS 'Number of apps with preview QR enabled (allow_preview = true) at snapshot day end.';
+ IS 'Apps with preview QR enabled at snapshot day end (allow_preview = true).';📝 Committable suggestion
Suggested change
🧰 Tools🪛 SQLFluff (4.2.2)[error] 5-5: Line is too long (90 > 80). (LT05) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -680,6 +680,18 @@ describe('logsnag revenue metric helpers', () => { | |
| expect(coreSnapshotQuery).not.toContain('si.plan_usage > 100') | ||
| expect(coreSnapshotQuery).not.toContain('o.has_usage_credits') | ||
| }) | ||
|
|
||
| it.concurrent('snapshots apps with preview QR enabled in the core global stats shard', () => { | ||
| const source = readFileSync(new URL('../supabase/functions/_backend/triggers/logsnag_insights.ts', import.meta.url), 'utf8') | ||
| const countFn = source.match(/async function countAppsWithPreview[\s\S]*?async function getTrialExtensionStats/)?.[0] ?? '' | ||
| const coreShard = source.match(/async function runCoreGlobalStatsShard[\s\S]*?async function getRegistersToday/)?.[0] ?? '' | ||
|
|
||
| expect(countFn).toContain('apps.allow_preview = true') | ||
| expect(countFn).toContain('apps.created_at <') | ||
| expect(countFn).toContain('snapshotEnd') | ||
| expect(coreShard).toContain('countAppsWithPreview(c, window.prevDayEnd)') | ||
| expect(coreShard).toContain('apps_with_preview,') | ||
| }) | ||
|
Comment on lines
+683
to
+694
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy lift Test the metric behavior instead of matching source text. Lines [685-694] only inspect implementation strings. They do not execute 🤖 Prompt for AI Agents |
||
| it.concurrent('normalizes logsnag insights retry payload counts', () => { | ||
| expect(logsnagInsightsTestUtils.normalizeLogsnagInsightsRetryCount('2')).toBe(2) | ||
| expect(logsnagInsightsTestUtils.normalizeLogsnagInsightsRetryCount(2.8)).toBe(2) | ||
|
|
||
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Propagate count failures instead of recording zero.
Lines [1507-1509] convert every database error into a valid-looking
0. The core shard can then persist that value as the snapshot, making a failed query indistinguishable from zero preview-enabled apps. Log the error and rethrow it so shard failure handling can retry the snapshot.Suggested error propagation
catch (error) { cloudlogErr({ requestId: c.get('requestId'), message: 'countAppsWithPreview error', error }) - return 0 + throw error }📝 Committable suggestion
🤖 Prompt for AI Agents