Skip to content

Commit

Permalink
Speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
BradHN1 committed Oct 18, 2023
1 parent 8b734f9 commit af4038f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
15 changes: 3 additions & 12 deletions src/carbon_calculator/carbonCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ def AllActionsList(self):
response = {}
actionList = []
for action in self.allActions:
if not self.allActions[action].initialized:
dummy = self.allActions[action].Query()

name = self.allActions[action].name
title = self.allActions[action].title
description = self.allActions[action].description
Expand Down Expand Up @@ -417,18 +420,6 @@ def __init__(self,name):
self.text = "" # "Explanation for the calculated results."
self.picture = ""

status, actionInfo = QuerySingleAction(self.name)
if status == VALID_QUERY:
self.id = actionInfo["id"]
self.title = actionInfo["title"]
self.description = actionInfo["description"]
self.helptext = actionInfo["helptext"]
self.questions = actionInfo["questionInfo"] # question with list of valid responses.
self.average_points = actionInfo["average_points"]
self.picture = actionInfo["picture"]
self.initialized = True


def Query(self):
status, actionInfo = QuerySingleAction(self.name)
if not self.id and status == VALID_QUERY:
Expand Down
7 changes: 6 additions & 1 deletion src/carbon_calculator/content/Questions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ refrigerator_energystar<ME>,ME,Is the current refrigerator an EnergyStar model?,
washer_energystar<ME>,ME,Is the current washer an EnergyStar model?,Choice,Yes,,No,,Not sure,,,,,,,,,,,
dryer_loads<ME>,ME,How many dryer loads do you do each week on average?,Number,,,,,,,,,,,,,0.0,14.0,4.0,
fraction_line_dry<ME>,ME,What fraction of wash loads would you dry on the line or drying rack?,Choice,None,,Some,,Half,,Most,,All,,,,,,,
how_many_trees<ME>,ME,How many trees did you plant,Number,,,,,,,,,,,,,0.0,1000.0,5.0,
plant_trees<ME>,ME,"Did you plant some trees, and will you raise them to maturity?",Choice,Yes,,No,how_many_trees,,,,,,,,,,,,
buy_sell_used,Reduce/Reuse,"When possible, will you buy or sell used goods rather than new?",Choice,Usually,,Sometimes,,Rarely,,Never,,,,,,,,,reduce_waste
reuse_containers,Reduce/Reuse,"When possible, will you use refillable containers (bags,mugs,bottles)",Choice,Usually,,Sometimes,,Rarely,,Never,,,,,,,,,reduce_waste
buy_bulk,Reduce/Reuse,"When possible, will you buy in bulk to minimize packaging?",Choice,Usually,,Sometimes,,Rarely,,Never,,,,,,,,,reduce_waste
Expand Down Expand Up @@ -195,4 +197,7 @@ fertilizer_applications,Yard/Landscaping,Will you choose to reduce your fertiliz
leaf_cleanup_gas_blower,Yard/Landscaping,Do you use a gas blower to clean leaves?,Choice,No,leaf_cleanup_blower_switch,Yes,,,,,,,,,,,,,rake_elec_blower
leaf_cleanup_blower_switch,Yard/Landscaping,Will you choose to switch from gas blower to rake or electric blower?,Choice,No,,Yes,,,,,,,,,,,,,rake_elec_blower
lawn_service,Yard/Landscaping,Do you use a landscape service to take care of your lawn?,Choice,Yes,,No,,,,,,,,,,,,,reduce_lawn_care
lawn_size,Yard/Landscaping,How large is your lawn?,Choice,Small (<500 sq ft),,Medium (500-2000 sq ft),,Sizable (2000-5000 sq ft),,Large (>5000 sq ft),,,,,,,,,"reduce_lawn_size,reduce_lawn_care,electric_mower"
lawn_size,Yard/Landscaping,How large is your lawn?,Choice,Small (<500 sq ft),,Medium (500-2000 sq ft),,Sizable (2000-5000 sq ft),,Large (>5000 sq ft),,,,,,,,,"reduce_lawn_size,reduce_lawn_care,electric_mower"
how_many_trees,Yard/Landscaping,How many trees will you plant and grow to maturity?,Number,,,,,,,,,,,,,0.0,1000.0,5.0,plant_trees
plant_trees,Yard/Landscaping,Will you plant one or more trees and raise them to maturity?,Choice,Yes,,No,how_many_trees,,,,,,,,,,,,
,Yard/Landscaping,,,,,,,,,,,,,,,,,,

0 comments on commit af4038f

Please sign in to comment.