Skip to content

Instantly share code, notes, and snippets.

@mford22392
Last active April 2, 2020 14:51
Show Gist options
  • Save mford22392/7ff73681909ea4cba0bff971ad93b88d to your computer and use it in GitHub Desktop.
Save mford22392/7ff73681909ea4cba0bff971ad93b88d to your computer and use it in GitHub Desktop.
# Note how you could easily make 50 the default, and have the elif statement return default
# while the else statement returns hard coded 40... it sort of makes "default" lose its meaning...
class ContactComponent(WeightedComponent):
def calculate_weight(self):
if seeking_reimbursement:
return 70
elif unsure:
return 50
else:
return self.default_weight # 40
# Same issue as above
class QuizComponent(WeightedComponent):
def calculate_weight(self):
if seeking_reimbursement or (self.quiz_results or self.catalog_error):
return 0
if is_unsure:
return 40
else:
return 50
# For the next four, we get "lucky" that is_unsure and default are the same...
# but I can very easily imagine a future where there is a different order for every answer to the portal question
# in which case each of these calculate_weights functions would need a 5-branch if/else block
class ReimbursementComponent(WeightedComponent):
def calculate_weight(self):
if seeking_reimbursement:
return 80
else:
return self.default_weight # 30
class CoachRecsComponent(WeightedComponent):
def calculate_weight(self):
if seeking_reimbursement:
return 60 if self.coach_recommendations else 0
else:
return self.default_weight if self.coach_recommendations else 0 # 80
class BookmarksComponent(WeightedComponent):
def calculate_weight(self):
if seeking_reimbursement:
return 50 if self.bookmarks else 0
else:
return self.default_weight if self.bookmarks else 0 # 70
class QuizRecsComponent(WeightedComponent):
def calculate_weight(self):
if seeking_reimbursement:
return 40 if self.quiz_results else 0
else:
return self.default_weight if self.quiz_results else 0 # 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment