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:
Semih
2026-05-25 02:22:21 +03:00
parent 985592aa73
commit 09438cf513
2 changed files with 18 additions and 27 deletions

View File

@@ -109,20 +109,6 @@ export default async function VinDecodePage({
> >
VIN list VIN list
</Link> </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&apos;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&apos;ler
</Link>
<Link <Link
href="/projects/sase/vin-decode/business" href="/projects/sase/vin-decode/business"
className={buttonVariants({ variant: "outline", size: "sm" })} className={buttonVariants({ variant: "outline", size: "sm" })}

View File

@@ -312,19 +312,24 @@ export async function getTrialFunnel(days = 90): Promise<TrialFunnelRow[]> {
AND q.created_at <= coalesce(t.trial_end, now()) AND q.created_at <= coalesce(t.trial_end, now())
GROUP BY t.user_id, t.converted GROUP BY t.user_id, t.converted
) )
SELECT SELECT bucket, trial_users, converted
CASE FROM (
WHEN decode_count = 0 THEN '0' SELECT
WHEN decode_count BETWEEN 1 AND 2 THEN '1-2' CASE
WHEN decode_count BETWEEN 3 AND 5 THEN '3-5' WHEN decode_count = 0 THEN '0'
WHEN decode_count BETWEEN 6 AND 10 THEN '6-10' WHEN decode_count BETWEEN 1 AND 2 THEN '1-2'
WHEN decode_count BETWEEN 11 AND 25 THEN '11-25' WHEN decode_count BETWEEN 3 AND 5 THEN '3-5'
ELSE '26+' WHEN decode_count BETWEEN 6 AND 10 THEN '6-10'
END AS bucket, WHEN decode_count BETWEEN 11 AND 25 THEN '11-25'
count(*) AS trial_users, ELSE '26+'
count(*) FILTER (WHERE converted = true) AS converted END AS bucket,
FROM trial_decode_counts count(*) AS trial_users,
GROUP BY bucket 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 ORDER BY
CASE bucket CASE bucket
WHEN '0' THEN 0 WHEN '0' THEN 0