Skip to content

Commit

Permalink
Add ordering on bill number for more consistency
Browse files Browse the repository at this point in the history
Bill number is a string, and doesn't sort correctly across years. So we still sort via date introduced first, then use bill number to break ties (bills introduced on the same day), which wouldn't have issues sorting bill numbers across years (since it's all on the same day).

Code reuse is a bit fucked, because this spans both the front-end and the back-end. The scraping order should be the same as the order shown to the user.
  • Loading branch information
limdingwen committed Jul 25, 2024
1 parent fd3d44b commit 2a88c3c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions site/src/app/bills/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async function getRecentBills() {
"bill_no, name, second_reading_date_type, second_reading_date, is_passed, passed_date, summary, pdf_url",
)
.order("date_introduced", { ascending: false })
.order("bill_no", { ascending: false })
.limit(20);
if (error) throw error;
return data;
Expand Down
1 change: 1 addition & 0 deletions supabase/functions/generate-bills-summary/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Deno.serve(async (req) => {
.not("original_text", "is", null)
.is("summary", null)
.order("date_introduced", { ascending: false })
.order("bill_no", { ascending: false })
.limit(1)
.maybeSingle();
if (selectError) throw selectError;
Expand Down
1 change: 1 addition & 0 deletions supabase/functions/scrape-bills-pdf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Deno.serve(async (req) => {
.select("id, pdf_url")
.is("original_text", null)
.order("date_introduced", { ascending: false })
.order("bill_no", { ascending: false })
.limit(1)
.maybeSingle();
if (selectError) throw selectError;
Expand Down

0 comments on commit 2a88c3c

Please sign in to comment.