Skip to content

Commit

Permalink
output consistent order to ensure that output doesn't change when
Browse files Browse the repository at this point in the history
postgres version changes
  • Loading branch information
ChenglimEar committed Jul 16, 2024
1 parent efa9973 commit a6e89bd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ do-import-spreadsheets:
./bin/remove-whitespace $(DATABASE_NAME) candidates Instagram
./bin/remove-whitespace $(DATABASE_NAME) candidates Twitter
./bin/remove-whitespace $(DATABASE_NAME) candidates Bio
./bin/make-null-empty $(DATABASE_NAME) candidates data_warning

echo 'DROP TABLE IF EXISTS referendums CASCADE;' | psql $(DATABASE_NAME)
./bin/create-table $(DATABASE_NAME) $(CSV_PATH) referendums
Expand Down
2 changes: 1 addition & 1 deletion calculators/committee_contribution_list_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def fetch
AND ("Start_Date" IS NULL OR "Tran_Date" >= "Start_Date")
AND ("End_Date" IS NULL OR "Tran_Date" <= "End_Date")
JOIN elections ON election_name = name
ORDER BY "Tran_Date" ASC, CONCAT("Tran_NamL", "Tran_NamF"), "Tran_Amt1" ASC, "Tran_Emp" ASC
ORDER BY "Tran_Date" ASC, CONCAT("Tran_NamL", "Tran_NamF"), "Tran_Amt1" ASC, "Tran_Emp" ASC, "Tran_Occ" DESC, "Tran_Zip4" ASC
SQL

contributions_by_committee = results.each_with_object({}) do |row, hash|
Expand Down
3 changes: 2 additions & 1 deletion calculators/election_top_contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def fetch
Sum("Tran_Amt1") as total_contributions
FROM "combined_contributions"
WHERE "election_name" <> ''
GROUP BY "election_name", name;
GROUP BY "election_name", name
ORDER BY "election_name", name;
SQL

results_by_election = election_results.each_with_object({}) do |result, hash|
Expand Down

0 comments on commit a6e89bd

Please sign in to comment.