iati-data-access / data-backend

GNU Affero General Public License v3.0
1 stars 0 forks source link

Error 500 when rolling up by years and quarters #27

Closed markbrough closed 6 months ago

markbrough commented 6 months ago

When running this query, there is an error 500: https://cdfd.iati.opendataservices.coop/api/babbage/cubes/iatiline/aggregate/?drilldown=activity.iati_identifier|activity.title_en|reporting_organisation&order=value_usd.sum:desc&cut=transaction_type.code:%223%22;%224%22|calendar_year_and_quarter:%222023%20Q1%22;%222023%20Q2%22;%222023%20Q3%22;%222023%20Q4%22|recipient_country_or_region.code:%22ET%22|reporting_organisation.code:%22US-GOV-1%22|sector_category.code:%22120%22&aggregates=value_usd.sum&rollup=calendar_year_and_quarter:[[%222023%20Q1%22],[%222023%20Q2%22],[%222023%20Q3%22],[%222023%20Q4%22]]&pagesize=1048576&format=xlsx&lang=en

The issue appears to be caused here: https://github.com/iati-data-access/data-backend/blob/bf9cdb7a9b0739039ad98d1ec3011c830dd51f5a/iatidatacube/xlsx_writer.py#L33-L34

As calendar_year_and_quarter does not have a code attribute or a label_en attribute: https://github.com/iati-data-access/data-backend/blob/bf9cdb7a9b0739039ad98d1ec3011c830dd51f5a/models/iatiline.json#L614-L622