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

Search, filter and sort. #107

Merged
merged 24 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6da6337
Adding the filtering database by tag and api endpoint
PaulaPerdomo Nov 10, 2023
fa01d94
Added get method to the filtering
jioh-kim Nov 10, 2023
e0562cc
Merge branch 'main' into filtering
jioh-kim Nov 10, 2023
631ef30
Changed filter to use jasonify
jioh-kim Nov 10, 2023
7ff5993
Added datalayer method for search filter and sort combined
meriam04 Nov 12, 2023
9358d22
Validated api for /fliter
meriam04 Nov 12, 2023
aaa8445
Adding the filtering by location, club and time intervals
PaulaPerdomo Nov 12, 2023
f3fab43
Changed the queries so that none fields are not used in queries
meriam04 Nov 12, 2023
b1b6d4f
Added datalayer and api calls to get all locations and all clubs for …
jioh-kim Nov 12, 2023
fd706d9
Added frontend for filtering. Can do multiple tags at once. Still nee…
tmahabir Nov 12, 2023
be76853
Merge branch 'filtering' of https://github.com/ECE444-2023Fall/Blue-S…
tmahabir Nov 12, 2023
d2c1bf0
Frontend now fetches location and club names from backend to populate…
tmahabir Nov 12, 2023
037eb0d
Search bar now works with filters
tmahabir Nov 12, 2023
46dffa2
Frontend is now able to sort posts using sort dropdown
tmahabir Nov 12, 2023
a29d3c6
Frontend can now filter by date with just start time. Still need to i…
tmahabir Nov 12, 2023
a31a6ac
Fixed the bug with the filtering by date
PaulaPerdomo Nov 12, 2023
d82222b
Merging main into filtering
PaulaPerdomo Nov 13, 2023
dbfd24d
Adding a line to check if start is not NULL in onchange function in c…
PaulaPerdomo Nov 13, 2023
55ce1b1
Fixing the calendarr start and end times
PaulaPerdomo Nov 13, 2023
b8ad526
Added clear button for dates filter
tmahabir Nov 13, 2023
e2e3061
Merging main into the filtering branch
PaulaPerdomo Nov 13, 2023
5a420d4
Fixing issues with main
PaulaPerdomo Nov 13, 2023
cf5049c
Fixed app.py so it only populates the mock databse if it is SQlite an…
meriam04 Nov 13, 2023
e263c97
Ordering retrieved tags, locations and clubs for landing page
tmahabir Nov 13, 2023
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
75 changes: 75 additions & 0 deletions backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,43 @@ def get_all_tags():
500,
)

@app.route("/api/get-all-locations", methods=["GET"])
def get_all_locations():
try:
from .datalayer.event import EventDataLayer

event_data = EventDataLayer()
locations = event_data.get_all_locations()
return jsonify(locations)
except Exception as e:
error_message = str(e)
return (
jsonify(
{
"error": "Failed to get all locations",
"error message": error_message,
}
),
500,
)

@app.route("/api/get-all-clubs", methods=["GET"])
def get_all_clubs():
try:
from .datalayer.event import EventDataLayer

event_data = EventDataLayer()
clubs = event_data.get_all_clubs()
return jsonify(clubs)
except Exception as e:
error_message = str(e)
return (
jsonify(
{"error": "Failed to get all clubs", "error message": error_message}
),
500,
)

@app.route("/api/autosuggest", methods=["GET"])
def autosuggest():
query = request.args.get("query").lower()
Expand Down Expand Up @@ -533,6 +570,44 @@ def my_profile():
500,
)

@app.route("/api/filter", methods=["GET"])
def filter_tags():
try:
from .datalayer.event import EventDataLayer

event_data = EventDataLayer()

# start by getting the search results
query = request.args.get("query", default="").lower()
tagname = request.args.get("tag", None)
location = request.args.get("location", None)
club = request.args.get("club", None)
start_time = request.args.get("start_time", None)
end_time = request.args.get("end_time", None)
sortby = request.args.get("sortby", None)
events = event_data.search_filter_sort(
keyword=query,
tag_name=tagname,
location=location,
club=club,
start_time=start_time,
end_time=end_time,
sort_by=sortby,
)
print("returning event")
return jsonify_event_list(events)
except Exception as e:
error_message = str(e)
return (
jsonify(
{
"error": "Failed to search sort and filter events",
"error message": error_message,
}
),
500,
)

@app.route("/api/favourites", methods=["GET"])
@jwt_required() # new line
def my_favourites():
Expand Down
8 changes: 3 additions & 5 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@
setup_routes(app)

# Run populate_database only in development environment
if app.config.get("ENV") == "development" or app.config.get("ENV") == "testing":
print("Populating database...")
from .create_mock_db import populate_database

populate_database(app, db)
print("Populating database...")
from .create_mock_db import populate_database
populate_database(app, db)
tmahabir marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
app.run()
168 changes: 76 additions & 92 deletions backend/create_mock_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,100 +50,84 @@ def create_mock_events():
image_data = image_file.read()

events = [
(
Event(
title="Fall Career Week",
description="Meet top recruiters from leading companies.",
extended_description="The Fall Career Week is a premier event that offers a unique platform for students and recent graduates to connect with recruiters from top firms across the nation. Attendees will have the chance to network, learn about job opportunities, and gain insights into various industries. This event is perfect for those looking to start or advance their careers.",
location="online",
start_time=start_time,
end_time=end_time,
author_id=1,
is_published=True,
like_count=0,
club="YNCN, You're Next Career Networks",
image=image_data,
),
["Career Development"],
(Event(
title="Fall Career Week",
description="Meet top recruiters from leading companies.",
extended_description="The Fall Career Week is a premier event that offers a unique platform for students and recent graduates to connect with recruiters from top firms across the nation. Attendees will have the chance to network, learn about job opportunities, and gain insights into various industries. This event is perfect for those looking to start or advance their careers.",
location="online",
start_time=datetime.strptime("2023-10-28 09:00:00", "%Y-%m-%d %H:%M:%S"),
end_time=datetime.strptime("2023-11-28 11:00:00", "%Y-%m-%d %H:%M:%S"),
author_id=1,
is_published=True,
like_count=0,
club="YNCN, You're Next Career Networks",
image=image_data
),
(
Event(
title="Origami Workshop",
description="Discover the joy of paper folding.",
extended_description="Our Origami Workshop is designed for both beginners and those with some experience in the art of paper folding. Participants will learn the basic folds and techniques required to create beautiful origami models. From classic cranes to intricate flowers, the workshop provides a relaxing and rewarding experience for everyone involved.",
location="Bahen 8th Floor",
start_time=start_time,
end_time=end_time,
author_id=None,
is_published=True,
like_count=10,
club="Origami club",
image=image_data,
),
[],
),
(
Event(
title="Community Soccer Match",
description="Join us for a friendly soccer match.",
extended_description="The community soccer match is a weekly event that invites players of all skill levels to enjoy a fun and competitive game. It's a fantastic opportunity to stay active, meet new friends, and indulge in the love of the sport. Whether you're an experienced player or just looking to kick the ball around, the event is open to everyone.",
location="Varsity Stadium",
start_time=start_time,
end_time=end_time,
author_id=None,
is_published=True,
like_count=5,
club="Skule Soccer",
image=image_data,
),
[],
),
(
Event(
title="Hockey Game",
description="Come watch our varsity team play.",
extended_description="Join us at the Varisty Arena to watch our varsity hockey team play against Waterloo",
location="Varsity Arena",
start_time=start_time,
end_time=end_time,
author_id=None,
is_published=True,
like_count=10,
image=image_data,
),
["Clubs & Organizations", "Arts & Culture"],
),
(
Event(
title="Spanish Lessons",
description="Want to learn Spanish? Join our club.",
extended_description="The spanish lesson meetup is a weekly event that invites non native spanish speakers to learn.",
location="Bahen",
start_time=start_time,
end_time=end_time,
author_id=None,
is_published=True,
like_count=5,
club="Lesa",
image=image_data,
),
[],
),
(
Event(
title="Skateboard Contest",
description="Compete or just have fun at our skateboard contest.",
extended_description="Our annual skateboard contest is back, bigger and better than ever. Skateboarders from all over the city will come together to showcase their skills and compete for prizes. With categories for different age groups and skill levels, everyone from novices to pros can participate. Even if you're not competing, come enjoy the vibrant atmosphere and cheer on your favorite skaters.",
location="Galbraith",
start_time=start_time,
end_time=end_time,
author_id=None,
is_published=True,
like_count=10,
image=image_data,
),
["Clubs & Organizations", "Arts & Culture"],
["Career Development"]),
(Event(
title="Origami Workshop",
description="Discover the joy of paper folding.",
extended_description="Our Origami Workshop is designed for both beginners and those with some experience in the art of paper folding. Participants will learn the basic folds and techniques required to create beautiful origami models. From classic cranes to intricate flowers, the workshop provides a relaxing and rewarding experience for everyone involved.",
location="Bahen 8th Floor",
start_time=datetime.strptime("2023-10-28 08:00:00", "%Y-%m-%d %H:%M:%S"),
end_time=datetime.strptime("2023-10-28 12:00:00", "%Y-%m-%d %H:%M:%S"),
author_id=None,
is_published=True,
like_count=10,
club="Origami club",
image=image_data
),[]),
(Event(
title="Community Soccer Match",
description="Join us for a friendly soccer match.",
extended_description="The community soccer match is a weekly event that invites players of all skill levels to enjoy a fun and competitive game. It's a fantastic opportunity to stay active, meet new friends, and indulge in the love of the sport. Whether you're an experienced player or just looking to kick the ball around, the event is open to everyone.",
location="Varsity Stadium",
start_time=datetime.strptime("2023-11-18 13:00:00", "%Y-%m-%d %H:%M:%S"),
end_time=datetime.strptime("2023-11-28 13:30:00", "%Y-%m-%d %H:%M:%S"),
author_id=None,
is_published=True,
like_count=5,
club="Skule Soccer",
image=image_data
),[]),
(Event(
title="Hockey Game",
description="Come watch our varsity team play.",
extended_description="Join us at the Varisty Arena to watch our varsity hockey team play against Waterloo",
location="Varsity Arena",
start_time=datetime.strptime("2023-11-28 10:00:00", "%Y-%m-%d %H:%M:%S"),
end_time=datetime.strptime("2023-11-28 23:59:59", "%Y-%m-%d %H:%M:%S"),
author_id=None,
is_published=True,
like_count=10,
image=image_data
),
["Clubs & Organizations", "Arts & Culture", "Academic"]),
(Event(
title="Spanish Lessons",
description="Want to learn Spanish? Join our club.",
extended_description="The spanish lesson meetup is a weekly event that invites non native spanish speakers to learn.",
location="Bahen",
start_time=datetime.strptime("2024-02-28 09:00:00", "%Y-%m-%d %H:%M:%S"),
end_time=datetime.strptime("2024-02-28 11:00:00", "%Y-%m-%d %H:%M:%S"),
author_id=None,
is_published=True,
like_count=5,
club="Lesa",
image=image_data
),[]),
(Event(
title="Skateboard Contest",
description="Compete or just have fun at our skateboard contest.",
extended_description="Our annual skateboard contest is back, bigger and better than ever. Skateboarders from all over the city will come together to showcase their skills and compete for prizes. With categories for different age groups and skill levels, everyone from novices to pros can participate. Even if you're not competing, come enjoy the vibrant atmosphere and cheer on your favorite skaters.",
location="Galbraith",
start_time=start_time,
end_time=end_time,
author_id=None,
is_published=True,
like_count=10,
image=image_data
),[])
]
return events

Expand Down
Loading