Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Classes to Schema #152

Merged
merged 52 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0f7f8ce
Created activity model and many to many relationship with gym model; …
Apr 15, 2023
3878f6f
added activity model to import statements on init_db()
Apr 15, 2023
9936f9f
deleted testing objects in init_db()
Apr 15, 2023
0e495a1
deleted duplicate code
Apr 15, 2023
e7f65f5
Implemented PR edits in activity.py
Apr 19, 2023
bacd3ae
Implemented PR edits in gym.py
Apr 19, 2023
34f79d5
Implemented PR changes in schema.py and added Price and Amenity class…
Apr 19, 2023
045ae0c
Populated models to test
Apr 20, 2023
187cc14
Resolved merge conflicts
May 1, 2023
25669b1
Cleaning up some merge conflicts
May 1, 2023
2eebca9
almost implementing Facilities
Aug 28, 2023
0c9c96e
Merge branch 'master' into bella/schema
Sep 20, 2023
639c8c0
Created activity model and many to many relationship with gym model; …
Apr 15, 2023
75a748d
added activity model to import statements on init_db()
Apr 15, 2023
fbc3a0f
deleted testing objects in init_db()
Apr 15, 2023
55913ff
deleted duplicate code
Apr 15, 2023
0312ad7
Implemented PR edits in activity.py
Apr 19, 2023
2de324e
Implemented PR edits in gym.py
Apr 19, 2023
90a8334
Implemented PR changes in schema.py and added Price and Amenity class…
Apr 19, 2023
1726494
Populated models to test
Apr 20, 2023
305753a
Cleaning up some merge conflicts
May 1, 2023
4159a01
almost implementing Facilities
Aug 28, 2023
b88573a
Activity model and some changes to gym
Oct 11, 2023
9940ff2
Merge branch 'master' of github.com:cuappdev/uplift-backend into bell…
Oct 11, 2023
1650a55
Created some of gym scraper
Oct 17, 2023
6319953
fixed facility.py
Oct 17, 2023
5396f9b
wrote some of gym hour scraper
Oct 20, 2023
6bc5f7d
Merge branch 'master' of github.com:cuappdev/uplift-backend into bell…
Oct 21, 2023
228a261
Implement scraper for fitness center hours
Nov 1, 2023
537dc73
changed some of activities
Nov 1, 2023
43bdbb6
Merge branch 'bella/activity' of github.com:cuappdev/uplift-backend i…
Nov 2, 2023
b01e8ae
class changes
Nov 5, 2023
843b1c9
fixed type issues on gym_scraper
Nov 15, 2023
10ae6f3
bug fixes on the scraper
Nov 16, 2023
76493a0
Merge branch 'master' of github.com:cuappdev/uplift-backend into bell…
Nov 16, 2023
2ec86b9
fixing scraping hours
Nov 16, 2023
de30b57
Merge branch 'bella/gymscraper' of github.com:cuappdev/uplift-backend…
Nov 16, 2023
0c14694
fixing activities
Nov 19, 2023
5bd9789
Merge branch 'master' of github.com:cuappdev/uplift-backend into bell…
Nov 19, 2023
6664322
completed fixed activities
Nov 19, 2023
92a1cf5
modified gym_scraper to accomodate special_hours
Nov 19, 2023
30374ef
Merge branch 'master' of github.com:cuappdev/uplift-backend into bell…
Jan 30, 2024
01f7405
Scraped equipment and added it to the Schema
Feb 13, 2024
1b6ad7c
Upgrade python version for the test workflow
kidzegeye Feb 14, 2024
d7c0c0d
added back classes and class scraper
Feb 28, 2024
0300589
fixed scheduling of classes scraper and cleaned up code
Mar 1, 2024
c48b6b9
Merge branch 'master' into bella/classes
Mar 27, 2024
ff81d18
modified schema
Apr 8, 2024
4e3facb
testing login
Apr 17, 2024
2897945
Merge branch 'master' of github.com:cuappdev/uplift-backend
Apr 17, 2024
6d3fcf1
merging with master
Apr 17, 2024
bb101e5
added classes to schema
Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from flask import Flask, render_template
from flask import Flask, render_template, redirect, url_for
from flask_apscheduler import APScheduler
from flask_graphql import GraphQLView
from graphene import Schema
Expand Down Expand Up @@ -63,6 +63,13 @@ def scrape_capacities():

fetch_capacities()

# Scrape classes every hour
@scheduler.task("interval", id="scrape_classes", seconds=3600)
def scrape_classes():
logging.info("Scraping classes from group-fitness-classes...")

fetch_classes(3)


# Scrape classes every hour
@scheduler.task("interval", id="scrape_classes", seconds=3600)
Expand Down
24 changes: 24 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ type Capacity {
updated: Int!
}

type Class {
id: ID!
name: String!
description: String!
classInstances: [ClassInstance]
}

type ClassInstance {
id: ID!
gymId: Int
classId: Int!
location: String!
instructor: String!
isCanceled: Boolean!
isVirtual: Boolean!
startTime: DateTime
endTime: DateTime
class_: Class
gym: Gym
}

enum CourtType {
BASKETBALL
VOLLEYBALL
Expand All @@ -52,6 +73,8 @@ type CreateUser {
user: User
}

scalar DateTime

type EnterGiveaway {
giveawayInstance: GiveawayInstance
}
Expand Down Expand Up @@ -117,6 +140,7 @@ type Gym {
amenities: [Amenity]
facilities: [Facility]
hours: [OpenHours]
classes: [ClassInstance]
}

type Mutation {
Expand Down
4 changes: 2 additions & 2 deletions src/models/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Class(Base):
id = Column(Integer, primary_key=True)
name = Column(String(), nullable=False)
description = Column(String(), nullable=False)
gyms = relationship("ClassInstance", back_populates="class_")
class_instances = relationship("ClassInstance", back_populates="class_")

def __init__(self, **kwargs):
self.id = kwargs.get("id")
Expand All @@ -60,7 +60,7 @@ class ClassInstance(Base):
isVirtual = Column(Boolean(), nullable=False, default=False)
start_time = Column(DateTime(), nullable=True)
end_time = Column(DateTime(), nullable=True)
class_ = relationship("Class", back_populates="gyms")
class_ = relationship("Class", back_populates="class_instances")
gym = relationship("Gym", back_populates="classes")

def __init__(self, **kwargs):
Expand Down
33 changes: 33 additions & 0 deletions src/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,39 @@ class Price(SQLAlchemyObjectType):
class Meta:
model = PriceModel

# MARK: - Class


class Class(SQLAlchemyObjectType):
class Meta:
model = ClassModel

class_instances = graphene.List(lambda: ClassInstance)

def resolve_class_instances(self, info):
query = ClassInstance.get_query(info=info).filter(ClassInstanceModel.class_id == self.id)
return query



# MARK: - Class Instance


class ClassInstance(SQLAlchemyObjectType):
class Meta:
model = ClassInstanceModel

gym = graphene.Field(lambda: Gym)
class_ = graphene.Field(lambda: Class)

def resolve_gym(self, info):
query = Gym.get_query(info=info).filter(GymModel.id == self.gym_id).first()
return query

def resolve_class_(self, info):
query = Class.get_query(info=info).filter(ClassModel.id == self.class_id).first()
return query


# MARK: - Activity

Expand Down
Loading