Skip to content

feat(scanner): cross-country analytics views (#932)#945

Merged
ericsocrat merged 1 commit intomainfrom
feat/932-cross-country-analytics-views
Mar 17, 2026
Merged

feat(scanner): cross-country analytics views (#932)#945
ericsocrat merged 1 commit intomainfrom
feat/932-cross-country-analytics-views

Conversation

@ericsocrat
Copy link
Owner

Summary

Adds 3 read-only analytics views for cross-country scan and submission data, closing the final issue in epic #920.

Views Created

View Purpose Columns
v_cross_country_scan_analytics Per-country scan metrics (total, found, missed, miss rate, unique EANs) 7
v_cross_country_ean_candidates EANs scanned in >1 country — candidates for product_links 6
v_submission_country_analytics Per-country submission metrics (by status, acceptance rate) 7

Key Design Decisions

  • All views use CREATE OR REPLACE VIEW for idempotency
  • NULL scan_country / suggested_country rows excluded via WHERE clause
  • Views return 0 rows when no country-annotated data exists (backward safe)
  • No RLS on views — queryable via service_role/postgres for admin analytics

Files Changed

  • supabase/migrations/20260321000700_cross_country_analytics_views.sql — 3 new views
  • db/qa/QA__view_consistency.sql — 3 new checks (13 → 16)

Verification

supabase db reset --local          → migration applied cleanly
QA view consistency suite          → 16/16 checks pass (0 violations)
All 3 views verified               → correct column count and types

Closes #932
Part of epic #920

Copilot AI review requested due to automatic review settings March 17, 2026 17:28
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@vercel
Copy link

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tryvit Ready Ready Preview, Comment Mar 17, 2026 5:29pm

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds cross-country analytics surfaces in the database to support the country-aware scanner/submission epic (#920), by introducing 3 new read-only views and extending the QA view-consistency suite to validate their presence/shape.

Changes:

  • Add v_cross_country_scan_analytics for per-country scan hit/miss metrics.
  • Add v_cross_country_ean_candidates to identify EANs scanned in multiple countries (linking candidates).
  • Add v_submission_country_analytics for per-country submission status breakdown and acceptance rate, plus QA column-count checks for all 3 views.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
supabase/migrations/20260321000700_cross_country_analytics_views.sql Creates 3 new public analytics views over scan_history and product_submissions.
db/qa/QA__view_consistency.sql Adds QA checks to assert the new views exist and have expected column counts.

Comment on lines +50 to +54
CREATE OR REPLACE VIEW public.v_submission_country_analytics AS
SELECT
suggested_country,
count(*) AS total_submissions,
count(*) FILTER (WHERE status = 'pending') AS pending,
Comment on lines +9 to +13
CREATE OR REPLACE VIEW public.v_cross_country_scan_analytics AS
SELECT
scan_country,
count(*) AS total_scans,
count(*) FILTER (WHERE found = true) AS found_scans,
Comment on lines +29 to +33
CREATE OR REPLACE VIEW public.v_cross_country_ean_candidates AS
SELECT
ean,
array_agg(DISTINCT scan_country ORDER BY scan_country) AS scanned_in_countries,
count(DISTINCT scan_country) AS country_count,
@ericsocrat ericsocrat merged commit dbe0636 into main Mar 17, 2026
18 of 19 checks passed
@ericsocrat ericsocrat deleted the feat/932-cross-country-analytics-views branch March 17, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(scanner): cross-country scan and submission analytics views

2 participants