Skip to content

Commit e87b6e9

Browse files
committed
Add workout history field to User type
1 parent ee67ebd commit e87b6e9

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ type User {
318318
friends: [User]
319319
totalGymDays: Int!
320320
streakStart: DateTime
321+
workoutHistory: [Workout]
321322
}
322323

323324
type Workout {
@@ -333,4 +334,5 @@ type WorkoutGoalHistory {
333334
userId: Int!
334335
workoutGoal: Int!
335336
effectiveAt: DateTime!
337+
user: User
336338
}

src/schema.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ class Meta:
269269
streak_start = graphene.DateTime(
270270
description="The start datetime of the most recent active streak (midnight of the day in local timezone), up until the current date."
271271
)
272+
workout_history = graphene.List(lambda: Workout)
273+
274+
def resolve_workout_history(self, info):
275+
query = Workout.get_query(info).filter(WorkoutModel.user_id == self.id).order_by(WorkoutModel.workout_time.desc())
276+
return query.all()
272277

273278
def resolve_total_gym_days(self, info):
274279
return (

0 commit comments

Comments
 (0)