-
-
Notifications
You must be signed in to change notification settings - Fork 568
[4987] Annual Reports range Export #5274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @douten!
Thank you for this!
When doing the functional QA on this, I ran into an unanticipated situation.
On testing against production data, it looks like some of the reports have not been recalculated since new fields were added / changed. This results in the columns not lining up.
I want to discuss with the senior team and/or the stakeholder liaison what we should do in this situation, specifically whether we should just recalculate those reports -- which are currently only manually recalculated -- when we do the export.
So - this isn't a problem with what you've done, but we're going to have to hold moving forward on this PR while we decide what to do with this. The next meeting of the senior team is Sunday, so you won't have an answer until next week at least.
Thanks for the info @cielf |
@reports.each do |report| | ||
report_data = report.all_reports | ||
year = report['year'] | ||
values = report_data.flat_map { |r| r['entries'].values } | ||
csv_data << [year] + values | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Different reports end up having different columns. Here, instead of plucking out the values in the specific order, can you instead do a pass through all the reports and get all the headers and then build out a hash or something so that we can handle blank values and then go through and output the CSV based on that?
Something like this (note this is COMPLETELY UNTESTED SUGGESTION) :)
@reports.each do |report| | |
report_data = report.all_reports | |
year = report['year'] | |
values = report_data.flat_map { |r| r['entries'].values } | |
csv_data << [year] + values | |
end | |
@reports.each do |report| | |
report_data = report.all_reports | |
year = report['year'] | |
values = report_data.flat_map { |r| | |
headers.map { |field| r['entries'][field] } | |
} | |
csv_data << [year] + values | |
end |
That way if year 1 has some headers that year 2 doesn't have (or vice-versa) then we will get all of the entries.
I'm sorry -- I thought that we'd included the information that yes -- we can recalculate the reports. They do, however, still end up having different columns. |
Resolves #4987
Reviewer Notes
Description
/reports/annual_reports/range/{year_start}/{year_end}.csv
ex:
../reports/annual_reports/range/2023/2024.csv
earliest_reporting_year
andyear_start
will be usedyear_end
will be usedType of change
How Has This Been Tested?
Screenshots
Screen.Recording.2025-07-12.at.8.32.24.PM.mov