Allow level 'personal' for heating and electricity emissions
Closed this issue · 5 comments
Currently, the endpoints heatingAggregated
and electricityAggregated
only allow parameters 'group' and 'institute' for the query parameter level
.
However, this makes the individual dashboard unnecessary hard to compose because we would have to divide the group emissions by working group employees in the frontend. I would argue that this is a backend task.
Proposal:
Add something like the following to the resolve_heating_aggregation
and resolve_electricity_aggregation
functions:
if level == 'personal':
entries = Heating.objects.filter(
working_group__id=info.context.user.working_group.id
)
averaged_entries = entries / working_group/n_employees # somehow calculate average
Could you send the query using level=group
and then just use the value of co2e_cap
as co2e
for personal absolute co2e emissions?
But adding level=personal
as an option wouldn't be much work, I've actually just done it but the 'co2e' value is still the one for the whole group. Could be easily be changed to the value of 'co2e_cap' in the backend though.
But adding
level=personal
as an option wouldn't be much work, I've actually just done it but the 'co2e' value is still the one for the whole group. Could be easily be changed to the value of 'co2e_cap' in the backend though.
I've quickly implemented it, since it does seem like the cleaner solution to take care of the emission calculation in the backend. Opened a PR for it.
Can this be closed?