Closed dleard closed 1 year ago
Added high priority label based on Dylan's feedback that this should be done before next ciip cycle.
@BCerki @dleard is there an easy way of testing that in -dev, without access to the prod data?
you can't really test this any better in dev than what is written in the pgtap test (demo fixture).
Thank you! I'll mark it as approved then :) Thanks for the great work @BCerki and @dleard
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 withEmissionFactor
and a newEmissionFactorDefaultOrMeasured
has been added underEmissionFactor
.~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 anEmission 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 theMeasured 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 newEmission Factor
table.Implementation: We will keep the
Measured Emission Factor
materialized view to parse the old data, but remove the Measured Emission Factor table.emission_factor
materialized view. It should be similar to themeasured_emission_factor
materialized view, but updated with new xpaths to retrieve the data from the new tagsunit_name
orsub_unit_name
in the new materialized viewunit_name
andsub_unit_name
from themeasured_emission_factor
materialized viewemission_factor
table. It should have the same data asmeasured_emission_factor
with a few differences:unit_name
orsub_unit_name
columnsEmissionFactorType
column -> this column is derived from the metadata on theEmissionFactors
xml tagDefaultOrMeasured
column -> this column is derived from the data in theEmissionFactorDefaultOrMeasured
tagload_emission_factor()
function that inserts data from the oldmeasured_emission_factor
materialized view and then data from the newly createdemission_factor
materialized viewload()
function to replacemeasured_emission_factor
in the mv_array withemission_factor
load_measured_emission_factor
functionmeasured_emission_factor
table