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

Lily's branch #42

Open
wants to merge 71 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
7862f4a
updating name
AnyaKhemlani Nov 21, 2024
f0093b9
update home.py
AnyaKhemlani Dec 2, 2024
3088897
starting work on system admin pages
AnyaKhemlani Dec 2, 2024
34c1dd6
Added Student profile, with Image, Stats and Resumes
lilybedi Dec 2, 2024
3cd49a7
added logo + working on alumn pages
AnyaKhemlani Dec 2, 2024
3357937
made the colors match our brand identity
AnyaKhemlani Dec 2, 2024
86a4b4a
Update Home.py
AnyaKhemlani Dec 2, 2024
bc20b26
Merge branch 'anya's-branch'
AnyaKhemlani Dec 2, 2024
8e0551b
Add files via upload
tarinis1 Dec 5, 2024
6095260
Editing the Student info page
lilybedi Dec 5, 2024
f2c17a3
Added profile photo
lilybedi Dec 5, 2024
942b57f
Add files via upload
tarinis1 Dec 5, 2024
9fd51f6
Committing changes to Career_Compass_Database.sql file
Dec 5, 2024
814bdca
Redid the whole student page + proper naming
lilybedi Dec 5, 2024
ddf5be9
Committing working changes to database schema creation
Dec 5, 2024
4a7cf39
Stylistically Finalized Student Prof
lilybedi Dec 5, 2024
aeb8b6b
Made changes to schema format. changed Many to Many relationship for …
Dec 5, 2024
60a6ab4
about 2/3 done with refactoring of data
Dec 5, 2024
44043d2
Finished (atleast first draft) student profile page
lilybedi Dec 5, 2024
4c115b3
Adding the Alumni Majors and minor join tables to the schema
Dec 5, 2024
58f56f5
Progressing forward with updates to the DB schema
Dec 5, 2024
325ab0a
Trying to ensure that the data aligns with itself
Dec 5, 2024
88caad2
Preliminary job applications profile
lilybedi Dec 5, 2024
7a10468
Makes proper buttons
lilybedi Dec 5, 2024
ad1d022
Merge branch 'Lily's-Branch'
AnyaKhemlani Dec 5, 2024
40b96eb
Ensuring Application has a Many to Many relationship with student
Dec 5, 2024
fb15d70
trying to finish up table creation -- specifically relationship with …
Dec 5, 2024
5c9574b
fixed navbar in sutdent section
KalinaM11 Dec 5, 2024
b171a6f
Reverted the application because I made a mistake with StudentApplica…
Dec 5, 2024
3f17d27
fixed navabar for students
KalinaM11 Dec 5, 2024
d045ded
Finished modeling messages
Dec 5, 2024
037ec51
Deleting old template, going to run the database and see what happens
Dec 5, 2024
aa2f3bf
deleted csvs
KalinaM11 Dec 5, 2024
6d07816
Merge branch 'main' into kalina
KalinaM11 Dec 5, 2024
32653e7
Merge pull request #2 from lilybedi/kalina
KalinaM11 Dec 5, 2024
97284e2
Revert "Merge branch 'main' into kalina"
KalinaM11 Dec 5, 2024
7d226de
Merge pull request #3 from lilybedi/kalina
KalinaM11 Dec 5, 2024
1f87865
Adding changes to fix syntax
Dec 5, 2024
b9ee24e
Fixing order -- still getting compile problems
Dec 5, 2024
2f3de9f
Finally, this passes syntax and creates everything
Dec 5, 2024
e691f9b
Updated nav bar and advisor section
KalinaM11 Dec 5, 2024
26641bf
Merge pull request #4 from lilybedi/kalina
KalinaM11 Dec 5, 2024
6618d68
Making small change to create pull request
Dec 6, 2024
c152893
Merge pull request #5 from lilybedi/neel/database-creation/populating-db
neel-avancha Dec 6, 2024
1c86103
Created several pages, cosmetically functional
lilybedi Dec 6, 2024
9fba6ab
Committing the back-end file
Dec 6, 2024
496f65b
Committing working student routes, further testing/checking post routes
Dec 6, 2024
e3c5d77
All routes are tested and working outside of the cv upload one -- nee…
Dec 6, 2024
4fe6d1e
Changes to the company view postings
lilybedi Dec 6, 2024
6bb7a70
Lots of new things
lilybedi Dec 6, 2024
cdbec9b
Removed NorthWind
lilybedi Dec 6, 2024
7d7d10d
Removed sample pages
lilybedi Dec 6, 2024
bb27019
Removing unnecessary backend files
lilybedi Dec 6, 2024
d6cf722
Removing template files
lilybedi Dec 6, 2024
cdeb507
Removing more unnecessary files
lilybedi Dec 6, 2024
2cb44e2
Committing routes for Alumni as well as the student
Dec 6, 2024
fcaa0dc
Fixing route to show all postings
Dec 6, 2024
f3065af
Merge pull request #6 from lilybedi/neel/creating-routes
neel-avancha Dec 6, 2024
7ae9c6a
Connected Student Profile to database
lilybedi Dec 6, 2024
0bc9b32
Edit profile button!!
lilybedi Dec 6, 2024
ac13bc8
Prep job search (renamed Student Home) for new fixed routing
lilybedi Dec 6, 2024
3b6223a
Considerable progress on backend connection
lilybedi Dec 6, 2024
415e965
Potentially final commit before merging
lilybedi Dec 6, 2024
f0ddb0a
Merge branch 'main' into Lily's-Branch
lilybedi Dec 6, 2024
9f17d17
Fixing repo
lilybedi Dec 8, 2024
8507e75
Changes connecting student frontend to backend
lilybedi Dec 8, 2024
e5e686a
Changes
lilybedi Dec 8, 2024
745dd0e
Reworking of student's entire thing
lilybedi Dec 8, 2024
a9f8c0f
Changes to student profile
lilybedi Dec 8, 2024
9686100
FINAL job search
lilybedi Dec 8, 2024
f20b2ad
Final commit before merge
lilybedi Dec 8, 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
6 changes: 0 additions & 6 deletions api/.env.template

This file was deleted.

File renamed without changes.
208 changes: 208 additions & 0 deletions api/backend/advisor/advisor_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
from flask import Blueprint
from flask import request
from flask import jsonify
from flask import make_response
from flask import current_app
from backend.db_connection import db
from werkzeug.utils import secure_filename
import logging
#------------------------------------------------------------
# Create a new Blueprint object, which is a collection of
# routes.
advisors = Blueprint('advisors', __name__)



@advisors.route('/students/<int:advisor_id>', methods=['GET'])
def get_advisor_students(advisor_id):
"""Get all students for an advisor with their progress status (Story 1)"""
try:
query = '''
SELECT
s.ID,
s.First_Name,
s.Last_Name,
s.GPA,
CASE
WHEN s.Eligibility = 1 THEN 'TRUE'
ELSE 'FALSE'
END as Eligibility,
CASE
WHEN s.Hired = 1 THEN 'TRUE'
ELSE 'FALSE'
END as Hired,
COUNT(DISTINCT a.ID) as Total_Applications,
MAX(a.submittedDate) as Latest_Application,
(
SELECT st.Status_Description
FROM Application a2
JOIN Status st ON a2.Status_ID = st.ID
WHERE a2.Student_ID = s.ID
ORDER BY a2.submittedDate DESC
LIMIT 1
) as Latest_Status
FROM Student s
LEFT JOIN Application a ON s.ID = a.Student_ID
WHERE s.Advisor_ID = %s
GROUP BY s.ID;
'''
cursor = db.get_db().cursor()
cursor.execute(query, (advisor_id,))
return jsonify(cursor.fetchall()), 200
except Exception as e:
return jsonify({"error": str(e)}), 400


@advisors.route('/statistics/<int:advisor_id>', methods=['GET'])
def get_advisor_statistics(advisor_id):
"""Get summary statistics for an advisor's students (Story 3)"""
try:
cursor = db.get_db().cursor()

# Get total students and their status
status_query = '''
SELECT
COUNT(*) as Total_Students,
SUM(CASE WHEN Hired = TRUE THEN 1 ELSE 0 END) as Placed_Students,
SUM(CASE WHEN Hired = FALSE THEN 1 ELSE 0 END) as Searching_Students
FROM Student
WHERE Advisor_ID = %s AND Eligibility = TRUE
'''
cursor.execute(status_query, (advisor_id,))
status_stats = cursor.fetchone()

# Get application distribution
apps_query = '''
SELECT
COUNT(a.ID) as Applications_Count,
COUNT(DISTINCT a.Student_ID) as Students_Applied,
AVG(COUNT(a.ID)) OVER () as Avg_Applications_Per_Student
FROM Student s
LEFT JOIN Application a ON s.ID = a.Student_ID
WHERE s.Advisor_ID = %s AND s.Eligibility = TRUE
GROUP BY a.Student_ID
'''
cursor.execute(apps_query, (advisor_id,))
app_stats = cursor.fetchall()

return jsonify({
"status_statistics": status_stats,
"application_statistics": app_stats
}), 200
except Exception as e:
return jsonify({"error": str(e)}), 400



@advisors.route('/positions/filled/<int:advisor_id>', methods=['GET'])
def get_filled_positions(advisor_id):
"""Get information about filled positions (Story 4)"""
try:
query = '''
SELECT
p.ID,
p.Name,
p.Title,
c.Name AS Company_Name,
p.Filled,
p.Date_Start,
p.Date_End,
COUNT(DISTINCT a.ID) AS Total_Applications,
COUNT(DISTINCT CASE WHEN st.Status_Description = 'Accepted'
THEN a.ID END) AS Accepted_Applications
FROM Posting p
JOIN Company c ON p.Company_ID = c.ID
LEFT JOIN Application a ON p.ID = a.Position_ID
LEFT JOIN Status st ON a.Status_ID = st.ID
WHERE p.Filled = TRUE
GROUP BY p.ID
ORDER BY p.Date_End DESC;
'''
cursor = db.get_db().cursor()
cursor.execute(query)
return jsonify(cursor.fetchall()), 200
except Exception as e:
return jsonify({"error": str(e)}), 400




@advisors.route('/students/<int:advisor_id>/filter', methods=['GET'])
def filter_students_by_status(advisor_id):
"""Filter advisees based on co-op status (Story 5)"""
try:
hired = request.args.get('hired')
if hired is not None:
hired = hired.lower() == 'true'

current_app.logger.info(f"Advisor ID: {advisor_id}, Hired Filter: {hired}")

query = '''
SELECT
s.ID, s.First_Name, s.Last_Name, s.GPA,
c.Name as College_Name,
GROUP_CONCAT(DISTINCT f.Name) as Majors
FROM Student s
JOIN College c ON s.College_ID = c.ID
LEFT JOIN Student_Majors sm ON s.ID = sm.Student_ID
LEFT JOIN FieldOfStudy f ON sm.FieldOfStudy_ID = f.ID
WHERE s.Advisor_ID = %s AND s.Hired = %s AND s.Eligibility = TRUE
GROUP BY s.ID
'''
current_app.logger.info(f"Executing query: {query} with parameters: {(advisor_id, hired)}")

cursor = db.get_db().cursor()
cursor.execute(query, (advisor_id, hired))
results = cursor.fetchall()
current_app.logger.info(f"Query Results: {results}")
return jsonify(results), 200
except Exception as e:
current_app.logger.error(f"Error: {str(e)}")
return jsonify({"error": str(e)}), 400


@advisors.route('/term-summary/<int:advisor_id>', methods=['GET'])
def get_term_summary(advisor_id):
"""Get end-of-term summary data (Story 6)"""
try:
cursor = db.get_db().cursor()

# Get placement statistics
placement_query = '''
SELECT
cy.cycle,
COUNT(DISTINCT s.ID) as Total_Students,
SUM(CASE WHEN s.Hired = TRUE THEN 1 ELSE 0 END) as Placed_Students,
AVG(s.GPA) as Average_GPA,
COUNT(DISTINCT a.ID) as Total_Applications,
AVG(p.Pay) as Average_Salary
FROM Student s
JOIN Cycle cy ON s.Cycle = cy.ID
LEFT JOIN Application a ON s.ID = a.Student_ID
LEFT JOIN Posting p ON a.Position_ID = p.ID
WHERE s.Advisor_ID = %s AND s.Eligibility = TRUE
GROUP BY cy.cycle
'''
cursor.execute(placement_query, (advisor_id,))
placement_stats = cursor.fetchall()

# Get industry distribution
industry_query = '''
SELECT
p.Industry,
COUNT(DISTINCT s.ID) as Placed_Students
FROM Student s
JOIN Application a ON s.ID = a.Student_ID
JOIN Posting p ON a.Position_ID = p.ID
WHERE s.Advisor_ID = %s AND s.Hired = TRUE
GROUP BY p.Industry
'''
cursor.execute(industry_query, (advisor_id,))
industry_stats = cursor.fetchall()

return jsonify({
"placement_statistics": placement_stats,
"industry_distribution": industry_stats
}), 200
except Exception as e:
return jsonify({"error": str(e)}), 400
Loading