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

Kalina #39

Open
wants to merge 126 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 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
8882c7d
re-fixing home and modifying chat stuff
AnyaKhemlani 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
14df548
Merge branch 'main' into kalina
KalinaM11 Dec 5, 2024
20bdb19
Merge branch 'main' into kalina
KalinaM11 Dec 5, 2024
6618d68
Making small change to create pull request
Dec 6, 2024
e2729f4
added a students blueprint route and the advisor home page
KalinaM11 Dec 6, 2024
c152893
Merge pull request #5 from lilybedi/neel/database-creation/populating-db
neel-avancha Dec 6, 2024
f565ef5
Merge branch 'main' into kalina
KalinaM11 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
0a7ffb6
Merge branch 'main' into kalina
KalinaM11 Dec 6, 2024
3af3a77
Update Advisor_Home.py
KalinaM11 Dec 6, 2024
7ae9c6a
Connected Student Profile to database
lilybedi Dec 6, 2024
0bc9b32
Edit profile button!!
lilybedi Dec 6, 2024
71e22f4
Merge branch 'main' into anya's-branch
AnyaKhemlani 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
426bae0
alumni page to edit profile exists
AnyaKhemlani 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
2dd5463
Merge pull request #8 from lilybedi/Lily's-Branch
lilybedi Dec 6, 2024
fe395e5
Merge branch 'main' into kalina
KalinaM11 Dec 7, 2024
87faca9
Update student_routes.py
KalinaM11 Dec 7, 2024
4e1d4ad
merges
KalinaM11 Dec 7, 2024
894dd9b
Revert "merges"
KalinaM11 Dec 7, 2024
9433c3c
advisor routes
KalinaM11 Dec 7, 2024
6f2f3d3
Fixing syntax error so the student_routes will compile
Dec 7, 2024
ac3467d
Fixing breaking change, as well as committing here to ensure that rev…
Dec 7, 2024
bfb2b93
try to make alumni profile editable
AnyaKhemlani Dec 7, 2024
f5a34db
make it so they can add a co-op experience
AnyaKhemlani Dec 7, 2024
3ce3603
Testing the new routes committed. I added the ability for a student t…
Dec 7, 2024
297d9d8
Committing updates to jobPostings to be able to filter
Dec 7, 2024
e7ae5ca
added 3 pages to system admin
KalinaM11 Dec 7, 2024
7c85e67
Committing company routes from earlier -- need to now test the testab…
Dec 7, 2024
8b556e6
fixed merge conflict
KalinaM11 Dec 7, 2024
02c6120
fix merge conflict
KalinaM11 Dec 7, 2024
2534106
added back page 42
KalinaM11 Dec 7, 2024
dcd0f54
Committing the working implementation of the first two company routes…
Dec 7, 2024
9776124
The view applications route works as well. two more company routes to go
Dec 7, 2024
98accda
Finished testing the company routes these look goodgit add .git add .
Dec 7, 2024
975d0e6
Merge branch 'main' into anya's-branch
AnyaKhemlani Dec 7, 2024
1a55083
Committing first route for advisor -- more to go
Dec 7, 2024
4856248
Committing getting the statistics for an advisor's students
Dec 7, 2024
ae14ed7
Committing the get_filled_positions route
Dec 7, 2024
e954549
filter advisees based on co-op is done
Dec 7, 2024
2f83786
updated advisor page + insert statements for bridge table
KalinaM11 Dec 7, 2024
3e152be
finished 3 pages on advisor section
KalinaM11 Dec 7, 2024
6d5c539
Merge branch 'main' into kalina
KalinaM11 Dec 7, 2024
d9747d9
Advisor routes fully implemented and tested
Dec 7, 2024
a7335de
Merge pull request #9 from lilybedi/neel/finishing-back-end-functions
neel-avancha Dec 7, 2024
dd72b73
more alumn pages
AnyaKhemlani Dec 7, 2024
1e544fa
Merge branch 'main' into kalina
KalinaM11 Dec 7, 2024
d1c3b31
merged w main
KalinaM11 Dec 7, 2024
b133e5e
Committing first route of the system_admin!
Dec 7, 2024
69217db
make chat exist!
AnyaKhemlani Dec 7, 2024
bd36421
Merge pull request #12 from lilybedi/kalina
KalinaM11 Dec 7, 2024
5776610
Adding second system admin route
Dec 7, 2024
ab995e2
committing override capapbility for admin
Dec 7, 2024
0f5ed26
Fourth route for sys admin is done
Dec 7, 2024
4ac7ec9
Comitting the ability to see tickets for system admin
Dec 7, 2024
fd1467b
Comitting sixth route for sys_admin
Dec 7, 2024
8f15db2
Update Add_Alumn_Experience.py
AnyaKhemlani Dec 7, 2024
1abec90
Finally we have deletion
Dec 7, 2024
617ae86
Database changes
Dec 7, 2024
5ca3c30
Comitting the system_admin routes
Dec 7, 2024
4b7c9e6
Allowing alumni to display their associated students
Dec 7, 2024
c8f3b2d
finished back-end routes
Dec 7, 2024
e6612da
Merge branch 'main' into neel/finishing-back-end-functions
neel-avancha Dec 7, 2024
2ccdf85
Merge pull request #13 from lilybedi/neel/finishing-back-end-functions
neel-avancha Dec 7, 2024
140e37f
try to let alumn add an experience
AnyaKhemlani Dec 7, 2024
a4caa52
Merge branch 'main' into anya/user_id
AnyaKhemlani Dec 7, 2024
6441d04
fixed company pages
KalinaM11 Dec 7, 2024
87c00cd
Merge branch 'main' into kalina
KalinaM11 Dec 7, 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