@@ -249,14 +249,10 @@ class Query(graphene.ObjectType):
249249 get_workouts_by_id = graphene .List (Workout , id = graphene .Int (), description = "Get all of a user's workouts by ID." )
250250 activities = graphene .List (Activity )
251251 get_all_reports = graphene .List (Report , description = "Get all reports." )
252- get_workout_goals = graphene .List (
253- graphene .String , id = graphene .Int (required = True ), description = "Get the workout goals of a user by ID."
254- )
255- get_user_streak = graphene .Field (
256- graphene .JSONString ,
257- id = graphene .Int (required = True ),
258- description = "Get the current and max workout streak of a user." ,
259- )
252+ get_workout_goals = graphene .List (graphene .String , id = graphene .Int (required = True ),
253+ description = "Get the workout goals of a user by ID." )
254+ get_user_streak = graphene .Field (graphene .JSONString , id = graphene .Int (
255+ required = True ), description = "Get the current and max workout streak of a user." )
260256 get_hourly_average_capacities_by_facility_id = graphene .List (
261257 HourlyAverageCapacity , facility_id = graphene .Int (), description = "Get all facility hourly average capacities."
262258 )
@@ -363,6 +359,7 @@ def resolve_get_user_streak(self, info, id):
363359
364360 return {"active_streak" : active_streak , "max_streak" : max_streak }
365361
362+
366363 def resolve_get_hourly_average_capacities_by_facility_id (self , info , facility_id ):
367364 valid_facility_ids = [14492437 , 8500985 , 7169406 , 10055021 , 2323580 , 16099753 , 15446768 , 12572681 ]
368365 if facility_id not in valid_facility_ids :
@@ -533,6 +530,7 @@ class logWorkout(graphene.Mutation):
533530 class Arguments :
534531 workout_time = graphene .DateTime (required = True )
535532 user_id = graphene .Int (required = True )
533+ facility_id = graphene .Int (required = True )
536534
537535 Output = Workout
538536
@@ -541,8 +539,11 @@ def mutate(self, info, workout_time, user_id):
541539 user = User .get_query (info ).filter (UserModel .id == user_id ).first ()
542540 if not user :
543541 raise GraphQLError ("User with given ID does not exist." )
542+ facility = Facility .get_query (info ).filter (FacilityModel .id == facility_id ).first ()
543+ if not facility :
544+ raise GraphQLError ("Facility with given ID does not exist." )
544545
545- workout = WorkoutModel (workout_time = workout_time , user_id = user .id )
546+ workout = WorkoutModel (workout_time = workout_time , user_id = user .id , facility_id = facility . id )
546547
547548 db_session .add (workout )
548549 db_session .commit ()
0 commit comments