Skip to content

Commit

Permalink
logic for checking current season
Browse files Browse the repository at this point in the history
  • Loading branch information
Leland committed May 7, 2024
1 parent ef0fcdc commit 604d780
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Binary file modified server/application/__pycache__/scheduler.cpython-312.pyc
Binary file not shown.
Binary file modified server/application/__pycache__/suggestion_updater.cpython-312.pyc
Binary file not shown.
23 changes: 20 additions & 3 deletions server/application/suggestion_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def hourly_suggestion_emitter(socketio, suggestions):
print("Suggestions: ", suggestions)

def seasonal_suggestion_updater(suggestions):
suggestions_data = hybrid_season_suggester.suggest_price_change(1)
current_month = datetime.datetime.now().month
current_season = get_current_season(current_month)
suggestions_data = hybrid_season_suggester.suggest_price_change(current_season)
#suggestions.update(suggestions_data)
for category, items in suggestions_data.items():
if category in suggestions:
Expand All @@ -33,7 +35,9 @@ def seasonal_suggestion_updater(suggestions):


def seasonal_suggestion_emitter(socketio, suggestions):
suggestions_data = hybrid_season_suggester.suggest_price_change(1)
current_month = datetime.datetime.now().month
current_season = get_current_season(current_month)
suggestions_data = hybrid_season_suggester.suggest_price_change(current_season)
#suggestions.update(suggestions_data)
for category, items in suggestions_data.items():
if category in suggestions:
Expand All @@ -58,4 +62,17 @@ def convert_decimals_to_float(obj):
elif isinstance(obj, Decimal):
return float(obj)
else:
return obj
return obj


def get_current_season(month):
if month in [12, 1, 2]:
return "Winter"
elif month in [3, 4, 5]:
return "Spring"
elif month in [6, 7, 8]:
return "Summer"
elif month in [9, 10, 11]:
return "Fall"
else:
return "Unknown"

0 comments on commit 604d780

Please sign in to comment.