Skip to content

Commit

Permalink
Merge pull request #709 from TheRestartProject/RES-1957_tree_equivalence
Browse files Browse the repository at this point in the history
RES-1957 Switch on-platform CO2e emission stat to using tree equivalence
  • Loading branch information
edwh committed Dec 5, 2023
2 parents 7734690 + 2e8dde4 commit 3e6e30a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
6 changes: 4 additions & 2 deletions lang/en/partials.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@
'add_device_powered' => 'Add Powered Item',
'add_device_unpowered' => 'Add Unpowered Item',
'solution_text2' => 'Interesting case study to share?',
'emissions_equivalent_consume_low' => 'the same amount of emissions as<br /> watching :value day of TV non-stop|the same amount of emissions as<br /> watching :value days of TV non-stop',
'emissions_equivalent_consume_high' => 'the same amount of emissions as<br /> driving for :value km|the same amount of emissions as<br /> driving for :value km',
'emissions_equivalent_consume_low' => "that's like growing :value tree seedling for 10 years|that's like growing :value tree seedlings for 10 years",
'emissions_equivalent_consume_high' => "that's like planting around :value hectare of trees|that's like planting around :value hectares of trees",
'emissions_equivalent_consume_low_explanation' => 'Medium growth coniferous or deciduous trees, planted in an urban setting and grown for 10 years.',
'emissions_equivalent_consume_high_explanation' => 'Broadleaf tree seedlings grown in a plantation or woodlot in England for 1 year.',
'to_be_recycled' => ':value item to be recycled|:value items to be recycled',
'to_be_repaired' => ':value item to be repaired|:value items to be repaired',
'no_weight' => ':value misc or unpowered item with no weight estimate|:value misc or unpowered items with no weight estimate',
Expand Down
6 changes: 4 additions & 2 deletions lang/fr-BE/partials.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@
'add_device_unpowered' => 'Ajouter appareil non-électrique',
'are_you_sure' => 'Etes-vous sûr?',
'close' => 'Fermer',
'emissions_equivalent_consume_high' => 'La même quantité d\'émissions que<br /> conduire :value km|la même quantité d\'émissions que <br /> conduire :value km',
'emissions_equivalent_consume_low' => 'La même quantité d\'émissions que <br /> regarder :value jour la télévision sans arrêt|la même quantité d\'émissions que<br /> regarder :value jours la télévision sans arrêt',
'emissions_equivalent_consume_low' => "c'est comme cultiver un semis d'arbre de valeur pendant 10 ans|c'est comme cultiver :value semis d'arbres pendant 10 ans.",
'emissions_equivalent_consume_high' => "c'est comme planter environ 1 hectare d'arbres|c'est comme planter environ :value hectares d'arbres.",
'emissions_equivalent_consume_low_explanation' => 'Arbres à croissance moyenne, conifères ou feuillus, plantés en milieu urbain et cultivés pendant 10 ans.',
'emissions_equivalent_consume_high_explanation' => "Semis d'arbres feuillus cultivés dans une plantation ou un bois en Angleterre pendant 1 an.",
'loading' => 'Téléchargement',
'no_weight' => ':value objet(s) divers ou objet(s) non-électriques sans poids estimé(s)',
'please_confirm' => 'Veuillez confirmer que vous souhaitez continuer.',
Expand Down
6 changes: 4 additions & 2 deletions lang/fr/partials.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@
'add_device_unpowered' => 'Ajouter appareil non-électrique',
'are_you_sure' => 'Etes-vous sûr?',
'close' => 'Fermer',
'emissions_equivalent_consume_high' => 'La même quantité d\'émissions que<br /> conduire :value km|la même quantité d\'émissions que <br /> conduire :value km',
'emissions_equivalent_consume_low' => 'La même quantité d\'émissions que <br /> regarder :value jour la télévision sans arrêt|la même quantité d\'émissions que<br /> regarder :value jours la télévision sans arrêt',
'emissions_equivalent_consume_low' => "c'est comme cultiver un semis d'arbre de valeur pendant 10 ans|c'est comme cultiver :value semis d'arbres pendant 10 ans.",
'emissions_equivalent_consume_high' => "c'est comme planter environ 1 hectare d'arbres|c'est comme planter environ :value hectares d'arbres.",
'emissions_equivalent_consume_low_explanation' => 'Arbres à croissance moyenne, conifères ou feuillus, plantés en milieu urbain et cultivés pendant 10 ans.',
'emissions_equivalent_consume_high_explanation' => "Semis d'arbres feuillus cultivés dans une plantation ou un bois en Angleterre pendant 1 an.",
'loading' => 'Téléchargement',
'no_weight' => ':value objet(s) divers ou objet(s) non-électriques sans poids estimé(s)',
'please_confirm' => 'Veuillez confirmer que vous souhaitez continuer.',
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/StatsImpact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:description="equivalent_consumer(Math.round(stats.co2_total))"
unit="kg"
class="impact-co2"
:popover="popover_consumer(Math.round(stats.co2_total))"
/>
</div>
</div>
Expand Down
10 changes: 9 additions & 1 deletion resources/js/components/StatsValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
{{ percent }}%
</div>
<div class="impact-stat-subtitle" v-html="translatedSubtitle" />
<div v-if="description" class="impact-stat-description pt-3 m-3" v-html="translatedDescription" />
<div v-if="description && count > 0" class="impact-stat-description pt-3 m-3 d-flex" >
<span v-html="translatedDescription" />
<b-img v-if="popover" v-b-popover.html="popover" class="ml-2 icon-info clickable" src="/icons/info_ico_green.svg" />
</div>
<div class="image d-flex justify-content-around" v-if="image">
<b-img :src="image" />
</div>
Expand Down Expand Up @@ -96,6 +99,11 @@ export default {
type: String,
required: false,
default: null
},
popover: {
type: String,
required: false,
default: null
}
},
computed: {
Expand Down
22 changes: 17 additions & 5 deletions resources/js/mixins/co2equivalent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ export default {
equivalent_consumer(co2) {
let ret, val, key

if (co2 >= 3000) {
// Large value, compare to driving.
val = Math.round((1 / 0.12) * co2)
if (co2 >= 13501) {
// Large value, compare to hectares. 12 tonnes per hectare per year sourced from
// https://winrock.org/flr-calculator/
val = Math.round(co2 / 12000)
key = 'partials.emissions_equivalent_consume_high'
} else {
// Small value, compare to watching TV.
val = Math.round((1 / 0.024) * co2 / 24)
// Small value, compare to seedlings. 60kg sourced from https://www.epa.gov/energy/greenhouse-gas-equivalencies-calculator
val = Math.round(co2 / 60)
key = 'partials.emissions_equivalent_consume_low'
}

Expand All @@ -18,6 +19,17 @@ export default {
})

return ret
},
popover_consumer(co2) {
let key

if (co2 >= 13501) {
key = 'partials.emissions_equivalent_consume_high_explanation'
} else {
key = 'partials.emissions_equivalent_consume_low_explanation'
}

return this.$lang.get(key)
}
}
}

0 comments on commit 3e6e30a

Please sign in to comment.