Skip to content

Commit

Permalink
chore: Add more columsn to bulk_job_info
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 19, 2023
1 parent e855f3c commit 4fab405
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/pages/bulk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,18 @@ export default function Bulk({ onVerified }: BulkProps): React.ReactElement {
<Spacer />

<Table data={bulkJobs}>
<Table.Column prop="job_id" label="job_id" />
<Table.Column prop="bulk_job_id" label="job_id" />
<Table.Column prop="verified" label="Verified" />
<Table.Column
prop="number_of_emails"
label="Total emails"
/>
<Table.Column prop="created_at" label="Created At" />
<Table.Column prop="last_call_time" label="Finished At" />
<Table.Column prop="safe" label="Safe" />
<Table.Column prop="invalid" label="Invalid" />
<Table.Column prop="risky" label="Risky" />
<Table.Column prop="unknown" label="Unknown" />
</Table>
</Page>
</>
Expand Down
9 changes: 7 additions & 2 deletions src/supabase/database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface Database {
columns: ["bulk_job_id"];
isOneToOne: false;
referencedRelation: "bulk_jobs_info";
referencedColumns: ["job_id"];
referencedColumns: ["bulk_job_id"];
}
];
};
Expand Down Expand Up @@ -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;
};
Expand Down
10 changes: 7 additions & 3 deletions supabase/migrations/20231218194337_bulk_jobs_info.sql
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,4 +20,3 @@ CREATE VIEW bulk_jobs_info AS
bj.id
ORDER BY
bj.created_at DESC;

0 comments on commit 4fab405

Please sign in to comment.