diff --git a/src/pages/bulk.tsx b/src/pages/bulk.tsx index 117053ed..17a71446 100644 --- a/src/pages/bulk.tsx +++ b/src/pages/bulk.tsx @@ -118,13 +118,18 @@ export default function Bulk({ onVerified }: BulkProps): React.ReactElement { - + + + + + +
diff --git a/src/supabase/database.types.ts b/src/supabase/database.types.ts index 29326eae..f99e07bd 100644 --- a/src/supabase/database.types.ts +++ b/src/supabase/database.types.ts @@ -41,7 +41,7 @@ export interface Database { columns: ["bulk_job_id"]; isOneToOne: false; referencedRelation: "bulk_jobs_info"; - referencedColumns: ["job_id"]; + referencedColumns: ["bulk_job_id"]; } ]; }; @@ -373,9 +373,14 @@ export interface Database { Views: { bulk_jobs_info: { Row: { + bulk_job_id: number | null; created_at: string | null; - job_id: number | null; + invalid: number | null; + last_call_time: string | null; number_of_emails: number | null; + risky: number | null; + safe: number | null; + unknown: number | null; user_id: string | null; verified: number | null; }; diff --git a/supabase/migrations/20231218194337_bulk_jobs_info.sql b/supabase/migrations/20231218194337_bulk_jobs_info.sql index 9d073e60..0a499fcf 100644 --- a/supabase/migrations/20231218194337_bulk_jobs_info.sql +++ b/supabase/migrations/20231218194337_bulk_jobs_info.sql @@ -1,10 +1,15 @@ CREATE VIEW bulk_jobs_info AS SELECT - bj.id AS job_id, + bj.id AS bulk_job_id, bj.user_id, bj.created_at, COUNT(DISTINCT be.id) AS number_of_emails, - COUNT(DISTINCT CASE WHEN c.id IS NOT NULL THEN be.id ELSE NULL END) AS verified + COUNT(DISTINCT CASE WHEN c.id IS NOT NULL THEN be.id ELSE NULL END) AS verified, + SUM(CASE WHEN c.is_reachable = 'risky' THEN 1 ELSE 0 END) as risky, + SUM(CASE WHEN c.is_reachable = 'invalid' THEN 1 ELSE 0 END) as invalid, + SUM(CASE WHEN c.is_reachable = 'unknown' THEN 1 ELSE 0 END) as unknown, + SUM(CASE WHEN c.is_reachable = 'safe' THEN 1 ELSE 0 END) as safe, + MAX(c.created_at) as last_call_time FROM bulk_jobs bj LEFT JOIN @@ -15,4 +20,3 @@ CREATE VIEW bulk_jobs_info AS bj.id ORDER BY bj.created_at DESC; -