Skip to content

Commit

Permalink
fix(textile): apply durability to trims impacts. (#886)
Browse files Browse the repository at this point in the history
Apply durability to total impacts, Remove the `Accessoires` entry 
from the list in the "Impacts" sidebar tab, Remove the 
`Accessoires` entry the detailed "Impacts" tab in the comparator
  • Loading branch information
n1k0 authored Jan 9, 2025
1 parent 2601218 commit 99d1ff6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/Data/Textile/Simulator.elm
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ computeTotalTransportImpacts simulator =


computeTrims : Db -> Simulator -> Result String Simulator
computeTrims db simulator =
computeTrims db ({ durability } as simulator) =
simulator.inputs.trims
|> Component.compute db.textile
|> Result.map Component.extractImpacts
Expand All @@ -750,6 +750,7 @@ computeTrims db simulator =
Impact.sumImpacts
[ simulator.impacts
, trimsImpacts
|> Impact.divideBy (Unit.floatDurabilityFromHolistic durability)
]
, trimsImpacts = trimsImpacts
}
Expand Down
13 changes: 1 addition & 12 deletions src/Views/Comparator.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Views.Comparator exposing
)

import Data.Bookmark as Bookmark exposing (Bookmark)
import Data.Color as Color
import Data.Component as Component
import Data.Food.Recipe as Recipe
import Data.Impact as Impact
Expand Down Expand Up @@ -261,7 +260,6 @@ dataForIndividualImpacts definitions chartsData =
, "Utilisation de ressources en eau"
, "Utilisation de ressources fossiles"
, "Utilisation de ressources minérales et métalliques"
, "Accessoires"
]
|> List.indexedMap (\index label -> ( label, index ))
|> Dict.fromList
Expand Down Expand Up @@ -290,23 +288,14 @@ dataForIndividualImpacts definitions chartsData =
in
chartsData
|> List.map
(\{ complementsImpact, impacts, label, stepsImpacts } ->
(\{ complementsImpact, impacts, label } ->
let
complementImpacts =
Impact.complementsImpactAsChartEntries complementsImpact

entries =
impacts
|> Impact.getAggregatedScoreData definitions .ecoscoreData
-- Add an specific entry for trims impacts
|> (::)
{ color = Color.grey ++ "bb"
, name = "Accessoires"
, value =
stepsImpacts.trims
|> Maybe.map Unit.impactToFloat
|> Maybe.withDefault 0
}
|> List.sortWith labelComparison

reversed =
Expand Down
6 changes: 0 additions & 6 deletions src/Views/ImpactTabs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ view definitions { activeImpactsTab, complementsImpact, impactDefinition, onStep
, name = "Complément microfibres"
, value = -(Unit.impactToFloat complementsImpact.microfibers)
}

-- Textile trims
, { entryAttributes = []
, name = "Accessoires"
, value = Unit.impactToFloat (Maybe.withDefault Unit.noImpacts stepsImpacts.trims)
}
]
|> List.sortBy .value
|> List.reverse
Expand Down
42 changes: 21 additions & 21 deletions tests/e2e-textile.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,27 +298,27 @@
"trims[]=0e8ea799-9b06-490c-a925-37564746c454;1"
],
"impacts": {
"acd": 0.200213,
"cch": 26.8352,
"etf": 406.86,
"etf-c": 1001.58,
"fru": 270.868,
"fwe": 0.0135519,
"htc": 1.386e-8,
"htc-c": 6.09348e-9,
"htn": 2.4326e-7,
"htn-c": 1.03751e-7,
"ior": 16.2609,
"ldu": 315.242,
"mru": 0.00020443,
"ozd": 0.00008241,
"pco": 0.0831674,
"pma": 0.00000196483,
"swe": 0.0859008,
"tre": 0.462931,
"wtu": 6.86743,
"ecs": 4828.67,
"pef": 2978.38
"acd": 0.202355,
"cch": 26.866,
"etf": 409.943,
"etf-c": 1004.68,
"fru": 271.256,
"fwe": 0.0137218,
"htc": 1.42642e-8,
"htc-c": 6.1128e-9,
"htn": 2.71796e-7,
"htn-c": 1.06436e-7,
"ior": 16.2646,
"ldu": 315.942,
"mru": 0.000233825,
"ozd": 0.0000824104,
"pco": 0.083605,
"pma": 0.00000196985,
"swe": 0.0860145,
"tre": 0.464481,
"wtu": 6.87353,
"ecs": 4869.96,
"pef": 3027.52
}
},
{
Expand Down

0 comments on commit 99d1ff6

Please sign in to comment.