mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
chore: clear v1.11.2 QA-low cleanups
- Drop the unused `now` field from the coach `ExtractOpts` type; fact extraction never read it (conversation-summary keeps its own `now`). - Correct the no-ladder tiebreak docstring in measurement-read: the collapse picks the alphabetically smallest source name, matching the live-SQL `ORDER BY … source` tiebreak, not max count. - Replace the hand-inlined canonical-source subquery in the summaries rollup-path narrows query with `canonicalMeasurementsFrom(rank, "90 days")` for live/rollup parity with its siblings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0949fadfb0
commit
7923d75afe
3 files changed
+4
-24
No files matched your search
@@ -58,7 +58,6 @@ type RunCompletionFn = typeof runStatusCompletion;
|
||||
type PrismaLike = Pick<typeof prisma, "coachFact" | "coachConversation">;
|
||||
|
||||
interface ExtractOpts {
|
||||
now?: Date;
|
||||
runCompletion?: RunCompletionFn;
|
||||
prisma?: PrismaLike;
|
||||
locale?: string;
|
||||
|
||||
@@ -348,27 +348,7 @@ async function computeFromRollups(userId: string): Promise<SummariesSlice> {
|
||||
) FILTER (
|
||||
WHERE m."measured_at" >= NOW() - INTERVAL '90 days'
|
||||
)::double precision AS r2_90
|
||||
FROM (
|
||||
SELECT mm.*
|
||||
FROM measurements mm
|
||||
JOIN (
|
||||
SELECT DISTINCT ON ("type", date_trunc('day', "measured_at"))
|
||||
"type" AS t,
|
||||
date_trunc('day', "measured_at") AS d,
|
||||
"source" AS canon
|
||||
FROM measurements
|
||||
WHERE "user_id" = $1
|
||||
AND "deleted_at" IS NULL
|
||||
AND "measured_at" >= NOW() - INTERVAL '90 days'
|
||||
ORDER BY "type", date_trunc('day', "measured_at"), (${rankUnqualified}), "source"
|
||||
) c
|
||||
ON c.t = mm."type"
|
||||
AND c.d = date_trunc('day', mm."measured_at")
|
||||
AND c.canon = mm."source"
|
||||
WHERE mm."user_id" = $1
|
||||
AND mm."deleted_at" IS NULL
|
||||
AND mm."measured_at" >= NOW() - INTERVAL '90 days'
|
||||
) m
|
||||
FROM ${canonicalMeasurementsFrom(rankUnqualified, "90 days")}
|
||||
GROUP BY m."type"
|
||||
`,
|
||||
userId,
|
||||
|
||||
@@ -73,8 +73,9 @@ export interface SourcedBucketRow {
|
||||
* Resolution per bucket:
|
||||
* 1. the first source in the metric's ladder that is present → canonical;
|
||||
* 2. no ladder match (an unlisted source, or a type with no ladder) → the
|
||||
* row with the most readings (max `count`), tie-broken by source name,
|
||||
* so the bucket neither doubles nor goes dark.
|
||||
* row with the alphabetically smallest source name, so the bucket
|
||||
* neither doubles nor goes dark AND the pick matches the live-SQL
|
||||
* paths' `ORDER BY … source` tiebreak.
|
||||
*
|
||||
* Input order is preserved (buckets emit in first-seen order). A single-source
|
||||
* day (the common case) short-circuits to the row unchanged.
|
||||
|
||||
Reference in new issue
Block a user