Skip to content

Commit

Permalink
Renaming & doing some QA
Browse files Browse the repository at this point in the history
  • Loading branch information
voynow committed Aug 24, 2024
1 parent c58215c commit 8cdf50a
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 106 deletions.
8 changes: 4 additions & 4 deletions src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_athlete_full_name(strava_client) -> str:
return f"{athlete.firstname} {athlete.lastname}"


def run_gen_training_week_process(
def run_weekly_update_process(
user: UserRow,
upsert_fn: Callable[[str, TrainingWeekWithPlanning], None],
email_fn: Callable[[Dict[str, str], str, str], None],
Expand All @@ -60,7 +60,7 @@ def run_gen_training_week_process(
)


def run_update_training_week_process(
def run_mid_week_update_process(
user: UserRow,
upsert_fn: Callable[[str, MidWeekAnalysis, TrainingWeekWithPlanning], None],
email_fn: Callable[[Dict[str, str], str, str], None],
Expand Down Expand Up @@ -101,13 +101,13 @@ def core_executor(user: UserRow) -> None:

# day 6 is Sunday
if datetime_now_est.weekday() == 6:
run_gen_training_week_process(
run_weekly_update_process(
user=user,
upsert_fn=upsert_training_week_with_coaching,
email_fn=send_email,
)
else:
run_update_training_week_process(
run_mid_week_update_process(
user=user,
upsert_fn=upsert_training_week_update,
email_fn=send_email,
Expand Down
32 changes: 14 additions & 18 deletions src/supabase_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ def mock_upsert_training_week_with_coaching(
row_data = {
"athlete_id": athlete_id,
"training_week_planning": training_week_with_coaching.training_week_planning,
"training_week": json.dumps(
[session.dict() for session in training_week_with_coaching.training_week]
),
"training_week": [
session.dict() for session in training_week_with_coaching.training_week
],
"typical_week_training_review": training_week_with_coaching.typical_week_training_review,
"weekly_mileage_target": training_week_with_coaching.weekly_mileage_target,
}

# Log the data for testing purposes
print(f"Mock Upsert Data: {json.dumps(row_data, indent=2)}")
print(json.dumps(row_data, indent=4))
print(f"{training_week_with_coaching.total_weekly_mileage=}")
return APIResponse(data=[row_data], count=1)


Expand Down Expand Up @@ -208,21 +208,17 @@ def mock_upsert_training_week_update(

row_data = {
"athlete_id": athlete_id,
"activities": json.dumps(
[activity.dict() for activity in mid_week_analysis.activities]
),
"training_week": json.dumps(
[session.dict() for session in mid_week_analysis.training_week]
),
"activities": [activity.dict() for activity in mid_week_analysis.activities],
"training_week": [
session.dict() for session in mid_week_analysis.training_week
],
"planning": training_week_update_with_planning.planning,
"training_week_update": json.dumps(
[
session.dict()
for session in training_week_update_with_planning.training_week
]
),
"training_week_update": [
session.dict()
for session in training_week_update_with_planning.training_week
],
}
print(f"Mock Upsert Data: {json.dumps(row_data, indent=2)}")
print(json.dumps(row_data, indent=4))
return APIResponse(data=[row_data], count=1)


Expand Down
2 changes: 1 addition & 1 deletion src/training_week.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_weekly_mileage_target(
sysmsg = f"""{sysmsg_base}\nYou will be provided summary statistics (aggregated by week) of your client's training over the past several weeks."""
usermsg = f"""Starting from earliest to most recent, here are the weekly summaries:
{weekly_summaries}
As the coach, prescribe your client a target weekly mileage and long run range for next week. Be conservative when increasing volume & distance. Be specific and refer to the data provided. Write 2-3 sentences while being as concise as possible."""
As the coach, prescribe your client a target weekly mileage and long run range for next week. Be conservative when increasing volume & distance, it's important that the goals are very achievable. Be specific and refer to the data provided. Write 3-4 sentences while being as concise as possible."""
return get_completion(
[{"role": "assistant", "content": sysmsg}, {"role": "user", "content": usermsg}]
)
Expand Down
Loading

0 comments on commit 8cdf50a

Please sign in to comment.