@@ -116,7 +116,7 @@ class Meta:
116
116
model = CapacityModel
117
117
118
118
119
- #MARK - Hourly Average Capacity
119
+ # MARK - Hourly Average Capacity
120
120
class HourlyAverageCapacity (SQLAlchemyObjectType ):
121
121
class Meta :
122
122
model = HourlyAverageCapacityModel
@@ -252,7 +252,7 @@ def resolve_get_all_gyms(self, info):
252
252
def resolve_activities (self , info ):
253
253
query = Activity .get_query (info )
254
254
return query .all ()
255
-
255
+
256
256
def resolve_get_user_by_net_id (self , info , net_id ):
257
257
user = User .get_query (info ).filter (UserModel .net_id == net_id ).all ()
258
258
if not user :
@@ -296,7 +296,7 @@ def resolve_get_weekly_workout_days(self, info, id):
296
296
def resolve_get_all_reports (self , info ):
297
297
query = ReportModel .query .all ()
298
298
return query
299
-
299
+
300
300
def resolve_get_hourly_average_capacities_by_facility_id (self , info , facility_id ):
301
301
valid_facility_ids = [14492437 , 8500985 , 7169406 , 10055021 , 2323580 , 16099753 , 15446768 , 12572681 ]
302
302
if facility_id not in valid_facility_ids :
@@ -451,6 +451,20 @@ def mutate(self, info, description, issue, created_at, gym_id):
451
451
db_session .commit ()
452
452
return CreateReport (report = report )
453
453
454
+ class DeleteUserById (graphene .Mutation ):
455
+ class Arguments :
456
+ user_id = graphene .Int (required = True )
457
+ Output = User
458
+
459
+ def mutate (self , info , user_id ):
460
+ # Check if user exists
461
+ user = User .get_query (info ).filter (UserModel .id == user_id ).first ()
462
+ if not user :
463
+ raise GraphQLError ("User with given ID does not exist." )
464
+ db_session .delete (user )
465
+ db_session .commit ()
466
+ return user
467
+
454
468
455
469
class Mutation (graphene .ObjectType ):
456
470
create_giveaway = CreateGiveaway .Field (description = "Creates a new giveaway." )
@@ -459,6 +473,7 @@ class Mutation(graphene.ObjectType):
459
473
set_workout_goals = SetWorkoutGoals .Field (description = "Set a user's workout goals." )
460
474
log_workout = logWorkout .Field (description = "Log a user's workout." )
461
475
create_report = CreateReport .Field (description = "Creates a new report." )
476
+ delete_user = DeleteUserById .Field (description = "Deletes a user by ID." )
462
477
463
478
464
479
schema = graphene .Schema (query = Query , mutation = Mutation )
0 commit comments