Skip to content

Make the CO2 intensity figure settable per fund page - #86

Closed
taavipertman-glitch wants to merge 2 commits into
acf-investment-report-fieldsfrom
acf-co2-intensity-fields
Closed

Make the CO2 intensity figure settable per fund page#86
taavipertman-glitch wants to merge 2 commits into
acf-investment-report-fieldsfrom
acf-co2-intensity-fields

Conversation

@taavipertman-glitch

Copy link
Copy Markdown
Contributor

Summary

Moves the CO2 intensity figure for TUK75, TUK00 and TUV100 out of the markup and behind the fund_co2_intensity ACF field — the same field name TKF100 already uses — so the quarterly update stops needing a commit and a deploy.

Stacked on #69 (acf-investment-report-fields). Merge #69 first; I'll rebase onto master if you'd rather have it standalone.

Changes

  • helpers/acf/fund-pension.php — new Sustainability field group with fund_co2_intensity, for the three pension page templates
  • fund-stocks-details.php, fund-bonds-details.php, fund-third-details.phpget_field('fund_co2_intensity') ?: '<current figure>', output escaped
  • helpers/acf/fund-savings.phpshow_in_rest on group_fund_savings_details

Text field, not number

The three literals were inconsistent: 83.68 and 83.73 as floats, '133.80' quoted. That quoting is load-bearing — as a float it renders 133.8, dropping a significant digit. The field is text for the same reason, matching TKF100's existing field. I checked that sprintf('%s', …) output is identical for all three before and after, so nothing on the page changes until someone sets a field.

TKF100

fund_co2_intensity already exists for TKF100 but sits in group_fund_savings_details, which had no show_in_rest — so a REST write there would have hit the same silent no-op #69 fixes for the documents group. The flag is added here.

There is no CO2 figure for TKF100, and this does not invent one or start warning about it: the savings template already wraps the whole sustainability block in if ($fund_co2_intensity), so it stays hidden until a value exists.

Deploy notes

No visible change on merge — all four pages render exactly what they render today until a field is set. Automation is a separate step; note that the CO2 inputs are quarterly and partly manual (BlackRock/Xtrackers into apps/esg/co2-intensity.sql), so this removes the deploy from the loop, not the manual data gathering.

Same caveat as #69: ACF applies the group by page_template, so a REST write depends on the live pages being on the matching templates.

🤖 Generated with Claude Code

taavipertman-glitch and others added 2 commits August 14, 2026 15:14
TUK75, TUK00 and TUV100 carried the figure as a literal in the markup, so
every quarterly update meant a commit and a deploy. Add fund_co2_intensity
to the pension pages under the same name TKF100 already uses, with the
current figure as the fallback, so one field name serves all four funds.

The field is text rather than number because trailing zeros are
significant: TUK00's 133.80 renders as 133.8 once it becomes a float,
which is why that one literal was already quoted and the other two
were not.

Enable show_in_rest on group_fund_savings_details too, so TKF100's
existing field can be written the same way. TKF100 has no CO2 figure and
the savings template hides the block while the field is empty, so that
stays inert until a value exists.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The fallback literal has to stay -- it is what the page shows until someone
fills the field in -- but it also creates a second place the number can live,
and the field silently wins. The quarterly WACI update has been "edit these
three files" until now, so the next person to follow that habit on a fund whose
field is already set would change nothing and have no way to notice.

Comment only, no behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
taavipertman-glitch added a commit that referenced this pull request Sep 10, 2026
Ports what #69 and #86 carried that master still lacks, so both can be closed.

From #86: the CO2 intensity figure. It is not a document, but it has the same
problem — published on the fund page, updated on a cadence, and not the same
set for every fund — so it becomes a catalogue entry rather than a field group
of its own. That makes "no CO2 intensity is calculated for TKF100" an absent
line in the scope table instead of an empty field nobody can explain, and
publishing one later a scope-table edit. The catalogue is renamed from
documents to disclosures to stop the name lying about what it holds.

From #69: the generate_report_link() rewrite and its tests. Output is
unchanged for the three live report URLs, but the function no longer emits
unescaped HTML, keeps an absolute URL's own host instead of re-prefixing
get_site_url(), reads the reporting period from the filename rather than the
upload folder, and stops producing labels like "12.-1." from an unmatched
preg_match. All four matter more now that the URL arrives from an ACF field
rather than a literal in the template.

Rendered markup stays identical on all four fund pages.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@taavipertman-glitch

Copy link
Copy Markdown
Contributor Author

Superseded by #102. The CO2 figure is carried over there as a catalogue entry rather than its own Sustainability field group — same text-not-number reasoning, same three literals as fallbacks.

The gain is that "no CO2 intensity is calculated for TKF100" becomes an absent line in the scope table rather than an empty field with no explanation, and the savings template keeps its markup so publishing one later is a one-line scope edit.

One deliberate difference: group_fund_savings_details does not get show_in_rest, since nothing writes to that group over REST once CO2 leaves it.

Not deleting the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant