fix(vin-decode): repair Business page 500 + drop redundant VIN buttons
- Business page returned 500: getTrialFunnel's `ORDER BY CASE bucket ...` referenced the SELECT-list alias inside an expression, which Postgres can't resolve (error 42703 "column bucket does not exist"). Wrap the GROUP BY in a subquery so `bucket` is a real column the ORDER BY can use. Verified against prod: original errors, fixed query returns ordered buckets. - Remove the "Çözülen / Çözülemeyen VIN'ler" dashboard buttons — the VIN list already has a success/error status filter, so they were redundant. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -109,20 +109,6 @@ export default async function VinDecodePage({
|
||||
>
|
||||
VIN list →
|
||||
</Link>
|
||||
<Link
|
||||
href={`/projects/sase/vin-decode/vins?success=true&from=${encodeURIComponent(health.rangeStart.toISOString())}`}
|
||||
className={buttonVariants({ variant: "outline", size: "sm" })}
|
||||
title="Bu pencerede başarıyla çözülen VIN kodları"
|
||||
>
|
||||
✓ Çözülen VIN'ler
|
||||
</Link>
|
||||
<Link
|
||||
href={`/projects/sase/vin-decode/vins?success=false&from=${encodeURIComponent(health.rangeStart.toISOString())}`}
|
||||
className={buttonVariants({ variant: "outline", size: "sm" })}
|
||||
title="Bu pencerede çözülemeyen VIN kodları"
|
||||
>
|
||||
✗ Çözülemeyen VIN'ler
|
||||
</Link>
|
||||
<Link
|
||||
href="/projects/sase/vin-decode/business"
|
||||
className={buttonVariants({ variant: "outline", size: "sm" })}
|
||||
|
||||
@@ -312,19 +312,24 @@ export async function getTrialFunnel(days = 90): Promise<TrialFunnelRow[]> {
|
||||
AND q.created_at <= coalesce(t.trial_end, now())
|
||||
GROUP BY t.user_id, t.converted
|
||||
)
|
||||
SELECT
|
||||
CASE
|
||||
WHEN decode_count = 0 THEN '0'
|
||||
WHEN decode_count BETWEEN 1 AND 2 THEN '1-2'
|
||||
WHEN decode_count BETWEEN 3 AND 5 THEN '3-5'
|
||||
WHEN decode_count BETWEEN 6 AND 10 THEN '6-10'
|
||||
WHEN decode_count BETWEEN 11 AND 25 THEN '11-25'
|
||||
ELSE '26+'
|
||||
END AS bucket,
|
||||
count(*) AS trial_users,
|
||||
count(*) FILTER (WHERE converted = true) AS converted
|
||||
FROM trial_decode_counts
|
||||
GROUP BY bucket
|
||||
SELECT bucket, trial_users, converted
|
||||
FROM (
|
||||
SELECT
|
||||
CASE
|
||||
WHEN decode_count = 0 THEN '0'
|
||||
WHEN decode_count BETWEEN 1 AND 2 THEN '1-2'
|
||||
WHEN decode_count BETWEEN 3 AND 5 THEN '3-5'
|
||||
WHEN decode_count BETWEEN 6 AND 10 THEN '6-10'
|
||||
WHEN decode_count BETWEEN 11 AND 25 THEN '11-25'
|
||||
ELSE '26+'
|
||||
END AS bucket,
|
||||
count(*) AS trial_users,
|
||||
count(*) FILTER (WHERE converted = true) AS converted
|
||||
FROM trial_decode_counts
|
||||
GROUP BY 1
|
||||
) b
|
||||
-- ORDER BY references the real subquery column bucket; Postgres won't
|
||||
-- resolve a SELECT-list alias inside an expression in ORDER BY (42703).
|
||||
ORDER BY
|
||||
CASE bucket
|
||||
WHEN '0' THEN 0
|
||||
|
||||
Reference in New Issue
Block a user