bcgov / cas-ggircs

Climate Action Secretariat's Greenhouse Gas Industrial Reporting and Control System
Apache License 2.0
3 stars 4 forks source link

[CIIP 2023] Measured Emission Factor table does not parse records beyond 2017 [7] #457

Closed dleard closed 1 year ago

dleard commented 2 years ago

Probability: 5 - It will never parse data beyond 2017 Effect: 2

There was a change to the SWRS XML schema after 2017 that is causing our Measured Emission Factor table to data after 2017. We need to update our xpath logic to include this data.

It was noted in the metabase channel that the priority on this issue is "before the next reporting cycle".

Old schema: used a MeasuredEmissionFactor tag, our xpath currently looks for this tag in order to parse the data.

New Schema: MeasuredEmissionFactor has been replaced with EmissionFactor and a new EmissionFactorDefaultOrMeasured has been added under EmissionFactor.

~There a couple possible fixes here::~

~1) Keep the Measured Emission Factor table as is and adapt the transform materialized view to parse the data from newer reports (including the new tag so that results can be filtered & coalescing that value to 'measured' so that older reports under the old tag have a value). The benefit here being that any metabase questions currently using that table will be unaffected. Downside is that the table name isn't totally accurate since we're including emission factors that aren't necessarily 'measured'~

~2) Deprecate the Measured Emission Factor table in favor of an Emission Factor table. The solution here is the same as above as far as the code written, except we'd create a new table. This would make the table name align better with what it contains, but break any metabase questions currently using the Measured Emission Factor table.~

~To decide on a fix, it would be good to look at what effect dropping the Measured Emission Factor table would have on metabase. (drop the table in test and run the broken questions script).~

Update No questions in metabase rely on the Measured Emission Factor table. We can drop this table in favour of a new Emission Factor table.

Implementation: We will keep the Measured Emission Factor materialized view to parse the old data, but remove the Measured Emission Factor table.

Dianadec commented 1 year ago

Added high priority label based on Dylan's feedback that this should be done before next ciip cycle.

pbastia commented 1 year ago

@BCerki @dleard is there an easy way of testing that in -dev, without access to the prod data?

dleard commented 1 year ago

you can't really test this any better in dev than what is written in the pgtap test (demo fixture).

pbastia commented 1 year ago

Thank you! I'll mark it as approved then :) Thanks for the great work @BCerki and @dleard