Skip to content

Commit

Permalink
Merge branch 'feat/pull-v2-api' into add-workflow-to-gen-data
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenglimEar committed May 26, 2024
2 parents ffdc7e6 + 9fbfef3 commit 1e99f65
Show file tree
Hide file tree
Showing 19 changed files with 213 additions and 181 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ If you want to serve the static JSON files via a local web server:

## Developing

### Maintaining database schema

When `make import` is run, a number of postgres tables are created for importing the downloaded data. The schema of these tables are explicitly defined in the `dbschema` directory and may have to be updated in the future to accommodate future data. Columns that hold string data may not be sized large enough for future data. For example, if a name column accepts names of at most 20 characters and in the future, we have data where the name is 21 characters long, the data import will fail. When this occurs, we will have to update the corresponding schema file in `dbschema` to support more characters. Simply make the change and re-run `make import` to verify that it succeeds.

### Checking output data changes

This repository is used to generate data files that are used by the website. After `make process` is run, a `build` directory is generated containing the data files. This directory is checked in to the repository and later checked out when generating the website. After making code changes, it is important to compare the generated `build` directory against the `build` directory generated before the code changes and verify that changes from the code changes are as expected.
Expand All @@ -105,6 +109,8 @@ The expected changes are excluded before generating digests for data in the `bui

An additional script has been created to generate a report that enables comparing the totals for candidates. The script is `bin/report-candidates.py` and it generates `build/candidates.csv` and `build/candidates.xlsx`. The reports include a list of all the candidates and totals calculated multiple ways that should add up to the same number.

To ensure that database schema changes are visible in pull requests, the complete postgres schema is also saved to a `schema.sql` file in the `build` directory. Because the `build` directory is automatically re-built for each branch in a PR and committed to the repository, any change to the schema caused by a code change will be shown a difference in the `schema.sql` file when reviewing the PR.

### Adding a calculator

Each metric about a candidate is calculated independently. A metric might be
Expand Down
6 changes: 3 additions & 3 deletions build/_data/candidates/oakland/2018-11-06/pamela-price.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"supporting_money": {
"contributions_received": 109782.9,
"total_contributions": 109782.9,
"total_expenditures": 113921.91,
"total_expenditures": 114167.41,
"total_loans_received": 34500.0,
"total_supporting_independent": 0.0,
"support_list": [
Expand Down Expand Up @@ -51,7 +51,7 @@
"Candidate Filing/Ballot Fees": 1000.0,
"Campaign Literature and Mailings": 9979.27,
"Postage, Delivery and Messenger Services": 487.47,
"Professional Services (Legal, Accounting)": 58574.84,
"Professional Services (Legal, Accounting)": 58770.34,
"Information Technology Costs (Internet, E-mail)": 2019.74
},
"supporting_by_type": {
Expand All @@ -76,6 +76,6 @@
]
},
"total_contributions": 109782.9,
"total_expenditures": 113921.91,
"total_expenditures": 114167.41,
"total_loans_received": 34500.0
}
12 changes: 6 additions & 6 deletions build/_data/candidates/oakland/2023-11-07/jorge-c-lerma.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
"is_winner": null,
"filer_id": 1463520,
"supporting_money": {
"contributions_received": 16807.0,
"total_contributions": 16807.0,
"contributions_received": 17407.0,
"total_contributions": 17407.0,
"total_expenditures": 31588.37,
"total_loans_received": 0.0,
"total_supporting_independent": 0.0,
"support_list": [

],
"contributions_by_type": {
"Individual": 14838.0,
"Individual": 14238.0,
"Unitemized": 1469.0,
"Other (includes Businesses)": 500.0
"Other (includes Businesses)": 1700.0
},
"contributions_by_origin": {
"Out of State": 1200.0,
"Within Oakland": 10138.0,
"Within Oakland": 10738.0,
"Within California": 4000.0
},
"total_small_contributions": 1719.0,
Expand All @@ -58,7 +58,7 @@

]
},
"total_contributions": 16807.0,
"total_contributions": 17407.0,
"total_expenditures": 31588.37,
"total_loans_received": 0.0
}
25 changes: 19 additions & 6 deletions build/_data/committees/1463520.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"iec": false,
"total_contributions": 15338.0,
"total_contributions": 15938.0,
"contributions": [
{
"title": "Oakland November 7th, 2023 Special Election",
Expand Down Expand Up @@ -720,13 +720,26 @@
{
"title": "Oakland November 7th, 2023 Special Election",
"Filer_ID": "1463520",
"Tran_Emp": "Families in Action for Justice",
"Tran_Occ": "Chief Executive Officer",
"Entity_Cd": "Individual",
"Tran_Emp": null,
"Tran_Occ": null,
"Entity_Cd": "Other (includes Businesses)",
"Tran_Amt1": 600.0,
"Tran_Date": "2023-11-13",
"Tran_NamF": "Kimi",
"Tran_NamL": "Kean",
"Tran_NamF": null,
"Tran_NamL": "Families in Action for Justice",
"Tran_Zip4": "94621",
"election_name": "oakland-2023"
},
{
"title": "Oakland November 7th, 2023 Special Election",
"Filer_ID": "1463520",
"Tran_Emp": null,
"Tran_Occ": null,
"Entity_Cd": "Other (includes Businesses)",
"Tran_Amt1": 600.0,
"Tran_Date": "2023-11-13",
"Tran_NamF": null,
"Tran_NamL": "Families in Action for Justice",
"Tran_Zip4": "94621",
"election_name": "oakland-2023"
},
Expand Down
2 changes: 1 addition & 1 deletion build/_data/elections/oakland/2018-06-05.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"total_contributions": 15000.0
},
{
"name": "Oakland Athletics Baseball Company",
"name": "Service Employees International Union Local 1021 Issues PAC",
"type": "Measure",
"election_name": "oakland-june-2018",
"total_contributions": 10000.0
Expand Down
18 changes: 9 additions & 9 deletions build/_data/elections/oakland/2023-11-07.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"total_contributions": 35457.0,
"total_contributions": 36057.0,
"total_contributions_by_source": {
"Out of State": 1400.0,
"Within Oakland": 19934.0,
"Within Oakland": 20534.0,
"Within California": 11326.0
},
"contributions_by_type": {
"Committee": 6000.0,
"Individual": 26160.0,
"Individual": 25560.0,
"Unitemized": 3097.0,
"Other (includes Businesses)": 500.0
"Other (includes Businesses)": 1700.0
},
"most_expensive_races": [
{
"slug": "school-board-district-5",
"type": "office",
"title": "School Board District 5",
"amount": 35457.0
"amount": 36057.0
}
],
"largest_small_proportion": [
Expand Down Expand Up @@ -73,13 +73,13 @@
],
"top_contributors_for_offices": [
{
"name": "Service Employees International Union Local 1021 Candidate PAC",
"name": "UA Local 342",
"type": "Office",
"election_name": "oakland-2023",
"total_contributions": 1200.0
},
{
"name": "Oakland Education Association PAC",
"name": "Service Employees International Union Local 1021 Candidate PAC",
"type": "Office",
"election_name": "oakland-2023",
"total_contributions": 1200.0
Expand Down Expand Up @@ -108,7 +108,7 @@
"total_spending": 1200.0
},
{
"name": "Peralta Federation of Teachers COPE",
"name": "Families in Action for Justice",
"type": "Office",
"election_name": "oakland-2023",
"total_spending": 1200.0
Expand All @@ -128,7 +128,7 @@
"total_spending": 1200.0
},
{
"name": "Peralta Federation of Teachers COPE",
"name": "Families in Action for Justice",
"type": "Office",
"election_name": "oakland-2023",
"total_spending": 1200.0
Expand Down
4 changes: 2 additions & 2 deletions build/_data/elections/oakland/2024-03-05.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
],
"top_contributors_for_offices": [
{
"name": "Monique C Houston",
"name": "Steven Von Stade",
"type": "Office",
"election_name": "oakland-march-2024",
"total_contributions": 600.0
},
{
"name": "Steven Von Stade",
"name": "Monique C Houston",
"type": "Office",
"election_name": "oakland-march-2024",
"total_contributions": 600.0
Expand Down
6 changes: 3 additions & 3 deletions build/_data/elections/oakland/2024-11-05.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@
],
"top_contributors_for_offices": [
{
"name": "International Association of Firefighters Local 55",
"name": "International Federation of Professional and Technical Engineers-Local 21 TJ Anthony PAC Fund",
"type": "Office",
"election_name": "oakland-2024",
"total_contributions": 2400.0
},
{
"name": "International Federation of Professional and Technical Engineers-Local 21 TJ Anthony PAC Fund",
"name": "International Association of Firefighters Local 55",
"type": "Office",
"election_name": "oakland-2024",
"total_contributions": 2400.0
},
{
"name": "Todd Scanlin",
"name": "Weylin White",
"type": "Office",
"election_name": "oakland-2024",
"total_contributions": 1800.0
Expand Down
30 changes: 15 additions & 15 deletions build/_data/totals.json
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@
"total_contributions": 15000.0
},
{
"name": "Oakland Athletics Baseball Company",
"name": "Service Employees International Union Local 1021 Issues PAC",
"type": "Measure",
"election_name": "oakland-june-2018",
"total_contributions": 10000.0
Expand Down Expand Up @@ -1311,24 +1311,24 @@
]
},
"oakland-2023": {
"total_contributions": 35457.0,
"total_contributions": 36057.0,
"total_contributions_by_source": {
"Out of State": 1400.0,
"Within Oakland": 19934.0,
"Within Oakland": 20534.0,
"Within California": 11326.0
},
"contributions_by_type": {
"Committee": 6000.0,
"Individual": 26160.0,
"Individual": 25560.0,
"Unitemized": 3097.0,
"Other (includes Businesses)": 500.0
"Other (includes Businesses)": 1700.0
},
"most_expensive_races": [
{
"slug": "school-board-district-5",
"type": "office",
"title": "School Board District 5",
"amount": 35457.0
"amount": 36057.0
}
],
"largest_small_proportion": [
Expand Down Expand Up @@ -1385,13 +1385,13 @@
],
"top_contributors_for_offices": [
{
"name": "Service Employees International Union Local 1021 Candidate PAC",
"name": "UA Local 342",
"type": "Office",
"election_name": "oakland-2023",
"total_contributions": 1200.0
},
{
"name": "Oakland Education Association PAC",
"name": "Service Employees International Union Local 1021 Candidate PAC",
"type": "Office",
"election_name": "oakland-2023",
"total_contributions": 1200.0
Expand Down Expand Up @@ -1420,7 +1420,7 @@
"total_spending": 1200.0
},
{
"name": "Peralta Federation of Teachers COPE",
"name": "Families in Action for Justice",
"type": "Office",
"election_name": "oakland-2023",
"total_spending": 1200.0
Expand All @@ -1440,7 +1440,7 @@
"total_spending": 1200.0
},
{
"name": "Peralta Federation of Teachers COPE",
"name": "Families in Action for Justice",
"type": "Office",
"election_name": "oakland-2023",
"total_spending": 1200.0
Expand Down Expand Up @@ -1500,13 +1500,13 @@
],
"top_contributors_for_offices": [
{
"name": "Monique C Houston",
"name": "Steven Von Stade",
"type": "Office",
"election_name": "oakland-march-2024",
"total_contributions": 600.0
},
{
"name": "Steven Von Stade",
"name": "Monique C Houston",
"type": "Office",
"election_name": "oakland-march-2024",
"total_contributions": 600.0
Expand Down Expand Up @@ -1646,19 +1646,19 @@
],
"top_contributors_for_offices": [
{
"name": "International Association of Firefighters Local 55",
"name": "International Federation of Professional and Technical Engineers-Local 21 TJ Anthony PAC Fund",
"type": "Office",
"election_name": "oakland-2024",
"total_contributions": 2400.0
},
{
"name": "International Federation of Professional and Technical Engineers-Local 21 TJ Anthony PAC Fund",
"name": "International Association of Firefighters Local 55",
"type": "Office",
"election_name": "oakland-2024",
"total_contributions": 2400.0
},
{
"name": "Todd Scanlin",
"name": "Weylin White",
"type": "Office",
"election_name": "oakland-2024",
"total_contributions": 1800.0
Expand Down
2 changes: 1 addition & 1 deletion build/candidates.csv
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ merika-goolsby.json,oakland-2024-11-05,Merika Goolsby,0.0,0.0,0.0
zac-unger.json,oakland-2024-11-05,Zac Unger,125078.55,125078.55,125078.55
christian-miguel-martinez.json,oakland-2023-11-07,Christian Miguel Martinez,0.0,0.0,0.0
alexandra-ritzie-hernandez.json,oakland-2023-11-07,Alexandra Ritzie-Hernandez,18650.0,18950.0,18950.0
jorge-c-lerma.json,oakland-2023-11-07,Jorge C. Lerma,16807.0,16807.0,16807.0
jorge-c-lerma.json,oakland-2023-11-07,Jorge C. Lerma,17407.0,17407.0,17407.0
michael-houston.json,oakland-2024-03-05,Michael Houston,17745.0,17745.0,17745.0
bruce-quan.json,oakland-2016-11-08,Bruce Quan,75623.14,75623.14,75623.14
roseann-torres.json,oakland-2016-11-08,Roseann Torres,42403.01,42403.01,42403.01
Expand Down
Loading

0 comments on commit 1e99f65

Please sign in to comment.