Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
243 commits
Select commit Hold shift + click to select a range
b9783db
Created all api files
kanghosaeyo Aug 12, 2025
e2ac6ee
added database
kanghosaeyo Aug 12, 2025
45470a8
Merge pull request #1 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
60aee78
put stuff in the database
kanghosaeyo Aug 12, 2025
3f17845
Merge pull request #2 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
1dedfd4
Renamed folders
aga1936 Aug 12, 2025
06a60db
Renamed folders
aga1936 Aug 12, 2025
db8e240
added route for updating student profiles in /users
kanghosaeyo Aug 12, 2025
991d584
Merge pull request #3 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
d68d89e
query for finding status of application for student
aga1936 Aug 12, 2025
c00ede5
updated application status viewing api calls
kanghosaeyo Aug 12, 2025
7313d0f
Merge pull request #5 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
b37286d
Added company viewin
kanghosaeyo Aug 12, 2025
1a5507c
Merge pull request #6 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
a4f369c
added api for viewing avgPay per industry
kanghosaeyo Aug 12, 2025
9b459be
Merge pull request #7 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
a0a6962
Added and edited api routes for avg pay, placement data, company ratings
kanghosaeyo Aug 12, 2025
6342449
Merge pull request #8 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
55a02df
added api routes for identifying students with few apps
kanghosaeyo Aug 12, 2025
8b1d36e
Merge pull request #9 from kanghosaeyo/oscar
kanghosaeyo Aug 12, 2025
f225d16
added query for persona 1 to view num apps
aga1936 Aug 13, 2025
dc916b3
change position preference
aga1936 Aug 13, 2025
84a5d40
fixed error with applications route for students
aga1936 Aug 13, 2025
58842a9
fixed typo in function name in applications
aga1936 Aug 13, 2025
0fa835a
created main page
kanghosaeyo Aug 13, 2025
d64638f
Merge pull request #10 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
6c506fa
Added all the home pages for each persona
kanghosaeyo Aug 13, 2025
249a926
Merge pull request #11 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
6dd6c1c
api route for deadlines
aga1936 Aug 13, 2025
f44659d
Added mock data
kanghosaeyo Aug 13, 2025
000b6f7
Merge pull request #12 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
43ef2ab
deleted question mark
kanghosaeyo Aug 13, 2025
232e045
Merge pull request #13 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
a2412f9
api route for desired skills
aga1936 Aug 13, 2025
9819d26
Merge branch 'ana_antic'
aga1936 Aug 13, 2025
0c3939d
api for required skills
aga1936 Aug 13, 2025
427ccc8
Merge branch 'ana_antic'
aga1936 Aug 13, 2025
f53899a
Fixed database and updated student page
kanghosaeyo Aug 13, 2025
8d0cb8f
Merge branch 'main' of https://github.com/kanghosaeyo/Coopalytics int…
kanghosaeyo Aug 13, 2025
d7e8ae5
Merge pull request #14 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
91f360d
employer view profile
allymayo Aug 13, 2025
81f9905
ignor
kanghosaeyo Aug 13, 2025
d72a552
Merge pull request #15 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
379eaf4
reverted back to no api connection in student home, can someone help me
kanghosaeyo Aug 13, 2025
2c70f68
Merge pull request #16 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
23cded6
filter applicants
allymayo Aug 13, 2025
db3e8e5
added all pages + fixed side bar navigation
kanghosaeyo Aug 13, 2025
6b46845
Merge pull request #17 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
fca9d30
allow admins to review job postings before approval, shows unflagged …
suripeddis Aug 13, 2025
29ac429
exmployer post position
allymayo Aug 13, 2025
9749767
admine can review positions before they go live
suripeddis Aug 13, 2025
f209950
admin can review positions (redo)
suripeddis Aug 13, 2025
b3a8466
Merge pull request #18 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
eb31949
added api calls in student homepage and fixed mock data
kanghosaeyo Aug 13, 2025
55ae2a4
Merge pull request #19 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
5b45eeb
Add a simple admin list of jobs to review that shows unflagged co-op …
suripeddis Aug 13, 2025
07e5cb8
employer view applications
allymayo Aug 13, 2025
7df67d6
Merge pull request #20 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
9fb9899
Admin can approve a co-op positions by setting the flag to false
suripeddis Aug 13, 2025
c947e47
sets the flagged to false
suripeddis Aug 13, 2025
a409065
Merge pull request #21 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
df09a4e
Allow admins to delete unapproved or invalid co-op postings that are …
suripeddis Aug 13, 2025
82f22e9
setting flagged to true will delete a posting
suripeddis Aug 13, 2025
464b0a7
Merge pull request #22 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
7fe0601
Admins can now create employer student and advisor profiles by sendin…
suripeddis Aug 13, 2025
c387787
student creates aplication
allymayo Aug 13, 2025
b6f6a62
Merge pull request #23 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
e00791c
Allow admins to delete a user by sending a DELETE request with a user…
suripeddis Aug 13, 2025
8f2bfc1
Merge pull request #24 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
20b2ab9
Admin views preference metrics of different postings
suripeddis Aug 13, 2025
b0e50d5
Merge pull request #25 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
e83cb46
admin has the ability to flag a position with issues now
suripeddis Aug 13, 2025
e8bb57f
admin can flag positions that have issues
suripeddis Aug 13, 2025
03c061e
Merge pull request #26 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
89e5f34
admin can remove the flag on the coop position if it was fixed or cha…
suripeddis Aug 13, 2025
3b16b2a
Merge pull request #27 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
2bed251
Connected api with student home page + fixed database & mock data
kanghosaeyo Aug 13, 2025
10ca501
Merge pull request #28 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
8dee103
For each company this tells us how many applications came from each g…
suripeddis Aug 13, 2025
b4f0046
Merge pull request #29 from kanghosaeyo/saumya
suripeddis Aug 13, 2025
ca400e7
Merge branch 'main' into Ally
allymayo Aug 13, 2025
a003398
Merge pull request #31 from kanghosaeyo/Ally
kanghosaeyo Aug 13, 2025
812178c
remove employer view route
allymayo Aug 13, 2025
4dde230
Merge pull request #32 from kanghosaeyo/Ally
allymayo Aug 13, 2025
00f86d8
typo
kanghosaeyo Aug 13, 2025
0943393
Merge pull request #33 from kanghosaeyo/oscar
kanghosaeyo Aug 13, 2025
607cab7
fix routes
allymayo Aug 14, 2025
4798387
Merge pull request #34 from kanghosaeyo/Ally
allymayo Aug 14, 2025
60d96f6
updated routes for persona 1
aga1936 Aug 14, 2025
1e05e58
trouble shooting issues with student profile
aga1936 Aug 14, 2025
65733cc
fixed issues with api and routes to connect to db
aga1936 Aug 14, 2025
3850524
api routing edits
engamy Aug 14, 2025
ef41b03
updated Student_Home to fix errors with skills section
aga1936 Aug 14, 2025
c132baa
adding company profile user story routes
engamy Aug 14, 2025
4fd803a
resolving merge conflicts
engamy Aug 14, 2025
b953bce
figuring out the missing blueprint imports
suripeddis Aug 14, 2025
266bb70
Merge pull request #35 from kanghosaeyo/saumya
suripeddis Aug 14, 2025
bc7868f
merge main with branch Amy
engamy Aug 14, 2025
c4c9e37
Connect Admin Home Streamlit page to API for pending co-op positions …
suripeddis Aug 14, 2025
667a115
Merge pull request #37 from kanghosaeyo/saumya
suripeddis Aug 14, 2025
15dd448
trying to merge :(
suripeddis Aug 14, 2025
ca9c099
attempting to merge
suripeddis Aug 14, 2025
5b1704b
redoing the admin home again
suripeddis Aug 14, 2025
5f096d7
Created the calendar for Student to view deadlines for coops that the…
aga1936 Aug 14, 2025
8cec21e
Merge branch 'ana_antic'
aga1936 Aug 14, 2025
b4169f9
show the first 5 pending positions
suripeddis Aug 14, 2025
e1b56d9
show the first 5 pending positions
suripeddis Aug 14, 2025
6d5af26
Merge pull request #38 from kanghosaeyo/saumya
suripeddis Aug 14, 2025
47ba929
Added route to pull all co-op positions
aga1936 Aug 14, 2025
08ef7a2
Merge branch 'ana_antic'
aga1936 Aug 14, 2025
2fc3033
move admin to app instead of backend
suripeddis Aug 14, 2025
02b3a17
merge conflicts
suripeddis Aug 14, 2025
88b3e1d
added advisor home page
kanghosaeyo Aug 14, 2025
854a62c
changed API_BASE
suripeddis Aug 14, 2025
e624e0a
Merge pull request #40 from kanghosaeyo/oscar
kanghosaeyo Aug 14, 2025
37ac13f
see the pending coop positions
suripeddis Aug 14, 2025
31d9b4c
format
allymayo Aug 14, 2025
cd82a8e
Merge branch 'saumya'
suripeddis Aug 14, 2025
822b6d7
employer homepage
allymayo Aug 14, 2025
de35ead
employer pages
allymayo Aug 14, 2025
3223760
postings page title
allymayo Aug 14, 2025
6367ce3
redoing admin_home because nothing is loading/working
suripeddis Aug 14, 2025
2fd1b3b
remerging to see if this works
suripeddis Aug 14, 2025
5d27ccb
employer home page
allymayo Aug 14, 2025
b1d6830
started from scratch for admin home
suripeddis Aug 14, 2025
e4c7e42
Merge pull request #41 from kanghosaeyo/Ally
allymayo Aug 14, 2025
b948fe9
Resolved merge conflict in Admin Home page
suripeddis Aug 14, 2025
c4ad21d
implemented flagging in advisor
kanghosaeyo Aug 14, 2025
5238983
deleted unnecessary advisor route
kanghosaeyo Aug 14, 2025
25ba97b
Added the admin employer information
suripeddis Aug 14, 2025
b446bdb
Merge main←saumya: keep saumya version of Admin_Home
suripeddis Aug 14, 2025
0749cc1
co-op position view for students, has 404 error for retrieving positions
aga1936 Aug 14, 2025
d25446d
attempt at displaying all coop positions
engamy Aug 14, 2025
12c7479
attempting to display coop positions
engamy Aug 14, 2025
417aa54
Admin can now see the pending posts still approve button still not wo…
suripeddis Aug 14, 2025
07066e8
Created Advisor Analytics page
kanghosaeyo Aug 14, 2025
b02eaf3
checking merge properly
suripeddis Aug 14, 2025
e39b2ec
advisor-company ratings page
engamy Aug 14, 2025
7052cb0
advisor companies
engamy Aug 14, 2025
c5bf6d1
reverted changes
kanghosaeyo Aug 14, 2025
aa18f22
advisor company rating info
engamy Aug 14, 2025
9db1dd3
fixed api routes for admin employers
kanghosaeyo Aug 14, 2025
c3402db
adding admin postings now
suripeddis Aug 14, 2025
3a2a1b8
advisor company ratings
engamy Aug 14, 2025
52b8ce7
removing old comments
engamy Aug 14, 2025
8d3e29c
recommitting the admin postings because its not showing in the main
suripeddis Aug 15, 2025
91357e2
a
suripeddis Aug 15, 2025
1547cd4
Merge branch 'main' into saumya
suripeddis Aug 15, 2025
e30aa2e
Merge pull request #51 from kanghosaeyo/saumya
kanghosaeyo Aug 15, 2025
a05d0ae
fixed routing
kanghosaeyo Aug 15, 2025
c91f2fd
Merge pull request #52 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
9b4069b
fixed routes AGAIN
kanghosaeyo Aug 15, 2025
bb839cb
Merge pull request #53 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
03dad5a
Merge branch 'Amy'
engamy Aug 15, 2025
9a769d0
reset to working version for everyone, added in browse positions again
aga1936 Aug 15, 2025
8ddcda4
deleted prefixes and fixed api routes in student home and advisor home
kanghosaeyo Aug 15, 2025
f2292ba
Merge pull request #54 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
c5b9d5a
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
716033a
attempting student analytics
engamy Aug 15, 2025
71d582f
updated student browser positions again...
aga1936 Aug 15, 2025
071488a
student viewing past coop wage data
engamy Aug 15, 2025
55fbddc
updating DEI metrics (again)
suripeddis Aug 15, 2025
85e1d37
added remove preference button on browse coop postings
aga1936 Aug 15, 2025
20a23d9
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
746a93f
it's telling me to commit
engamy Aug 15, 2025
23c792a
more detail to coop postings for students
aga1936 Aug 15, 2025
4534a0d
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
317a027
cleaning up routing for users and company profiles
engamy Aug 15, 2025
d0f4915
cleaning up routing for users and companyProfiles
engamy Aug 15, 2025
5858f36
updated the student calendar
aga1936 Aug 15, 2025
405ab70
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
044a530
updated calendar
aga1936 Aug 15, 2025
db910a8
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
190e289
employer home page fixes
engamy Aug 15, 2025
3d3797a
employee home page fixes
engamy Aug 15, 2025
f55ca5e
Added a query to see metrics
suripeddis Aug 15, 2025
639e0b1
added query
suripeddis Aug 15, 2025
cb3b59e
DEI metrics now working
suripeddis Aug 15, 2025
257b2cf
Merge pull request #55 from kanghosaeyo/saumya
suripeddis Aug 15, 2025
4e2ddc2
Finalized Employer applications and employer candidates pages
kanghosaeyo Aug 15, 2025
9f7f151
Merge pull request #56 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
b62f34b
changed the view profile button to lead to the correct user profiles
kanghosaeyo Aug 15, 2025
8742429
Merge pull request #57 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
e3e16b8
fixed routes for company partnerships in advisor
kanghosaeyo Aug 15, 2025
6919973
Merge pull request #58 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
f954d94
employee home page fixes
engamy Aug 15, 2025
50ca915
implemented updating company+employer profile in page 20
kanghosaeyo Aug 15, 2025
4d74afb
Merge pull request #59 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
8510be8
added applications, fixed db issue
aga1936 Aug 15, 2025
57b5e13
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
820e0a3
pulling
suripeddis Aug 15, 2025
8d1d002
side bar manage co op
allymayo Aug 15, 2025
ecf84d8
Merge branch 'Ally'
allymayo Aug 15, 2025
3110853
finished setting up application submissions
aga1936 Aug 15, 2025
98acce6
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
c9c3f14
adding user routes for admin analytics
engamy Aug 15, 2025
815f9a7
adding user routes for admin analytics
engamy Aug 15, 2025
2ed9331
enhanced flagging in cooppositions, delete doesn't work yet and unfla…
kanghosaeyo Aug 15, 2025
02b4656
Merge pull request #60 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
6fdbbb2
fixed application status
aga1936 Aug 15, 2025
49e096c
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
2d095a2
admin analytics page
engamy Aug 15, 2025
8a735ba
platform admin analytics
engamy Aug 15, 2025
22d69e9
employer posting
allymayo Aug 15, 2025
56c9d8d
Merge branch 'Ally'
allymayo Aug 15, 2025
73f7ec1
accidentally removed some insert statements--adding them back here
engamy Aug 15, 2025
c8053e9
cleaned up comments in code for students
aga1936 Aug 15, 2025
959eb06
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
582edd3
cleaning up code
engamy Aug 15, 2025
39d6320
cleaning up code
engamy Aug 15, 2025
5e14fa4
deleted folders/files from class example
aga1936 Aug 15, 2025
6ce32bf
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
55b3168
deleted duplicate of workedatpos inserts
aga1936 Aug 15, 2025
af88d18
Resolved merge conflict between main and ana_antic
aga1936 Aug 15, 2025
ac420f5
adding advisor student management page
engamy Aug 15, 2025
ccb5fd8
adding advisor student management page
engamy Aug 15, 2025
1334b2a
updated comments
aga1936 Aug 15, 2025
2820861
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
3946869
deleted conflict markers
aga1936 Aug 15, 2025
1f1f39d
editing admin analytics UI
engamy Aug 15, 2025
e8e4233
deleted some features in home and employer
suripeddis Aug 15, 2025
076768b
tried to Resolve merge conflict in 02-coopalytics-data.sql
aga1936 Aug 15, 2025
d419082
cleaning up admin analytics UI
engamy Aug 15, 2025
0626012
removing a feature in admin and employer
suripeddis Aug 15, 2025
094bc43
Created readme
kanghosaeyo Aug 15, 2025
c60fed2
Merge pull request #61 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
8d3b6ab
deleted duplicate in inserts again...
aga1936 Aug 15, 2025
0e14af9
deleted duplicate in inserts again
aga1936 Aug 15, 2025
1bfa421
needed to fix inserts again
aga1936 Aug 15, 2025
fbeee35
fixing the merge conflict again again
aga1936 Aug 15, 2025
af42230
Update README.md
kanghosaeyo Aug 15, 2025
171212d
Update README.md
kanghosaeyo Aug 15, 2025
936e898
updating my branch
suripeddis Aug 15, 2025
d8ec442
advisor student management page UI improvements
kanghosaeyo Aug 15, 2025
f4d131b
Merge pull request #62 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
4a81d4c
updated to have 125 skilldetails table entry
aga1936 Aug 15, 2025
fc5a9ec
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
3bbf0bb
deleted tatus file
kanghosaeyo Aug 15, 2025
1955515
Merge pull request #63 from kanghosaeyo/oscar
kanghosaeyo Aug 15, 2025
871716c
added more employers
aga1936 Aug 15, 2025
48905c0
Merge branch 'ana_antic'
aga1936 Aug 15, 2025
5b1cd74
attempting merge
suripeddis Aug 15, 2025
4a856ad
fixed the delete issue in employers page on admin
suripeddis Aug 15, 2025
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
File renamed without changes.
459 changes: 400 additions & 59 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ SECRET_KEY=someCrazyS3cR3T!Key.!
DB_USER=root
DB_HOST=db
DB_PORT=3306
DB_NAME=northwind
MYSQL_ROOT_PASSWORD=<put a good password here>
DB_NAME=coopalytics
MYSQL_ROOT_PASSWORD=" "
56 changes: 56 additions & 0 deletions api/backend/advisoradvisee/advisoradvisee_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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

advisoradvisee = Blueprint('advisoradvisee', __name__)

# Advisor identifies students with too few applications
@advisoradvisee.route('/advisor/<advisorID>/students/low-applications', methods=['GET'])
def get_students_with_low_applications(advisorID):
current_app.logger.info('GET /advisor/<advisorID>/students/low-applications route')

query = '''
SELECT u.userId,
u.firstName,
u.lastName,
COUNT(apps.applicationId) AS totalApps
FROM advisor_advisee aa
JOIN users u ON u.userId = aa.studentId
LEFT JOIN appliesToApp ata ON ata.studentId = u.userId
LEFT JOIN applications apps ON ata.applicationId = apps.applicationId
WHERE aa.advisorId = {0}
GROUP BY u.userId, u.firstName, u.lastName
HAVING COUNT(apps.applicationId) < 5
ORDER BY totalApps ASC, u.lastName;
'''.format(advisorID)

cursor = db.get_db().cursor()
cursor.execute(query)
theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response

# Admin reassigns students to different advisors as needed
@advisoradvisee.route('/admin/<studentId>/<advisorId>',
methods = ['PUT'])
def reassignAdvisor():
current_app.logger.info('PUT /admin/<studentId>/<advisorId> route')
advisorId = request.json
studentId = request.json

query = '''
UPDATE advisor_advisee
SET advisorId = %s
WHERE studentId = %s;
'''
data=(advisorId, studentId)
cursor = db.get_db().cursor()
r = cursor.execute(query, data)
db.get_db().commit()
return 'advisor reassigned successfully'

256 changes: 256 additions & 0 deletions api/backend/applications/applications_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
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
import pymysql

# New Blueprint for applications
applications = Blueprint('applications', __name__)


# Student viewing their own application statuses
@applications.route('/student/<studentID>/applications', methods=['GET'])
def get_student_applications(studentID):
current_app.logger.info(f'GET /student/{studentID}/applications route')

query = '''
SELECT u.userId,
u.firstName,
u.lastName,
a.applicationId,
a.status AS applicationStatus,
a.resume,
a.coverLetter,
a.gpa,
cp.title AS positionTitle,
cp.deadline AS applicationDeadline,
a.dateTimeApplied,
cp.description AS positionDescription
FROM users u
JOIN appliesToApp ata ON u.userId = ata.studentId
JOIN applications a ON ata.applicationId = a.applicationId
JOIN coopPositions cp ON a.coopPositionId = cp.coopPositionId
WHERE u.userId = %s
ORDER BY a.dateTimeApplied DESC, cp.deadline ASC
'''

connection = db.get_db()

cursor = connection.cursor(pymysql.cursors.DictCursor)
cursor.execute(query, (studentID,))
theData = cursor.fetchall()

return make_response(jsonify(theData), 200)

# student sees how many positions they have applied to
@applications.route('/student/<studentID>/applications/summary', methods=['GET'])
def get_numb_apps(studentID):
current_app.logger.info('GET /student/<studentID>/applications route')

query = '''
SELECT a.status,
COUNT(*) AS ApplicationCount
FROM applications a
JOIN appliesToApp ata ON a.applicationId = ata.applicationId
WHERE ata.studentId = %s
GROUP BY a.status

'''

cursor = db.get_db().cursor()
cursor.execute(query, (studentID,))
theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response



# Advisor viewing all their advisees' application statuses
@applications.route('/advisor/<advisorID>/students/applications', methods=['GET'])
def get_advisor_student_applications(advisorID):
current_app.logger.info('GET /advisor/<advisorID>/students/applications route')

query = '''
SELECT aa.advisorId,
u.userId,
u.firstName,
u.lastName,
a.applicationId,
a.status AS applicationStatus,
cp.title AS positionTitle,
cp.deadline AS applicationDeadline,
com.name AS companyName,
a.dateApplied
FROM advisor_advisee aa
JOIN users u ON aa.studentId = u.userId
JOIN appliesToApp ata ON u.userId = ata.studentId
JOIN applications a ON ata.applicationId = a.applicationId
JOIN coopPositions cp ON a.coopPositionId = cp.coopPositionId
JOIN companyProfiles com ON cp.companyProfileId = com.companyProfileId
LEFT JOIN workedAtPos wp ON u.userId = wp.studentId AND wp.coopPositionId = cp.coopPositionId
WHERE aa.advisorId = {0}
ORDER BY u.lastName, u.firstName, a.dateApplied DESC
'''.format(advisorID)

cursor = db.get_db().cursor()
cursor.execute(query)
theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response

# Employer views all applications of a posting
@applications.route('/applications/<int:coopPositionId>', methods=['GET'])
def get_applications(coopPositionId):
current_app.logger.info('GET /applications/%s', coopPositionId)

query = '''
SELECT a.dateTimeApplied, a.status, a.resume, a.gpa, a.coverLetter,
a.coopPositionId, a.applicationId
FROM applications a
JOIN coopPositions cp ON a.coopPositionId = cp.coopPositionId
WHERE a.coopPositionId = %s
ORDER BY a.dateTimeApplied DESC;
'''
cursor = db.get_db().cursor()
cursor.execute(query, (coopPositionId,))
theData = cursor.fetchall()

return make_response(jsonify(theData), 200)

# NEW ENDPOINT: Employer views all applications with student details for a specific position
@applications.route('/applications/<int:coopPositionId>/with-students', methods=['GET'])
def get_applications_with_students(coopPositionId):
current_app.logger.info('GET /applications/%s/with-students', coopPositionId)

query = '''
SELECT a.dateTimeApplied, a.status, a.resume, a.gpa, a.coverLetter,
a.coopPositionId, a.applicationId,
u.userId as studentId, u.firstName, u.lastName, u.email,
u.major, u.minor, u.college, u.gradYear, u.grade
FROM applications a
JOIN appliesToApp ata ON a.applicationId = ata.applicationId
JOIN users u ON ata.studentId = u.userId
JOIN coopPositions cp ON a.coopPositionId = cp.coopPositionId
WHERE a.coopPositionId = %s
ORDER BY a.dateTimeApplied DESC;
'''
cursor = db.get_db().cursor()
cursor.execute(query, (coopPositionId,))
theData = cursor.fetchall()

return make_response(jsonify(theData), 200)

# NEW ENDPOINT: Update application status (for employers)
@applications.route('/applications/<int:applicationId>/status', methods=['PUT'])
def update_application_status(applicationId):
current_app.logger.info('PUT /applications/%s/status', applicationId)

try:
request_data = request.json
new_status = request_data.get('status')

if not new_status:
return make_response(jsonify({"error": "Status is required"}), 400)

# Validate status values
valid_statuses = ['Draft', 'Submitted', 'Under Review', 'Accepted', 'Rejected']
if new_status not in valid_statuses:
return make_response(jsonify({"error": "Invalid status"}), 400)

query = '''
UPDATE applications
SET status = %s
WHERE applicationId = %s
'''

cursor = db.get_db().cursor()
cursor.execute(query, (new_status, applicationId))

if cursor.rowcount == 0:
return make_response(jsonify({"error": "Application not found"}), 404)

db.get_db().commit()

return make_response(jsonify({
"success": True,
"applicationId": applicationId,
"newStatus": new_status
}), 200)

except Exception as e:
current_app.logger.error(f"Error updating application status: {e}")
return make_response(jsonify({"error": "Internal server error"}), 500)

# NEW ENDPOINT: Get single application details by application ID
@applications.route('/applications/<int:applicationId>/details', methods=['GET'])
def get_application_details(applicationId):
current_app.logger.info('GET /applications/%s/details', applicationId)

query = '''
SELECT a.applicationId, a.dateTimeApplied, a.status, a.resume, a.gpa, a.coverLetter,
a.coopPositionId, cp.title as positionTitle, cp.location, cp.hourlyPay,
cp.deadline, cp.industry, cp.description as positionDescription,
u.userId as studentId, u.firstName, u.lastName, u.email,
u.major, u.minor, u.college, u.gradYear, u.grade
FROM applications a
JOIN appliesToApp ata ON a.applicationId = ata.applicationId
JOIN users u ON ata.studentId = u.userId
JOIN coopPositions cp ON a.coopPositionId = cp.coopPositionId
WHERE a.applicationId = %s
'''

cursor = db.get_db().cursor()
cursor.execute(query, (applicationId,))
theData = cursor.fetchall()

if not theData:
return make_response(jsonify({"error": "Application not found"}), 404)

return make_response(jsonify(theData[0]), 200)

# Student applies to a position
@applications.route('/applications/new', methods=['POST'])
def create_application():
current_app.logger.info('POST /applications/new')

data = request.json
required_fields = ['coopPositionId', 'studentId']

if not all(field in data for field in required_fields):
current_app.logger.warning('POST /applications/new missing required fields')
return make_response(jsonify({"error": "coopPositionId and studentId are required"}), 400)

try:
cursor = db.get_db().cursor()

# Insert application
cursor.execute('''
INSERT INTO applications (resume, gpa, coverLetter, coopPositionId)
VALUES (%s, %s, %s, %s)
''', (
data.get('resume', ''),
data.get('gpa'),
data.get('coverLetter', ''),
data['coopPositionId']
))

application_id = cursor.lastrowid

# Link student to application
cursor.execute('''
INSERT INTO appliesToApp (applicationId, studentId)
VALUES (%s, %s)
''', (application_id, data['studentId']))

db.get_db().commit()
return jsonify({"message": "Application submitted", "applicationId": application_id}), 201

except Exception as e:
current_app.logger.error(f"❌ Error creating application: {e}")
return jsonify({"error": str(e)}), 500 # Temporarily return full error for debugging
42 changes: 42 additions & 0 deletions api/backend/companyProfiles/companyProfiles_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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

companyProfiles = Blueprint('companyProfiles', __name__)

# Student/Advisor views a company profile
@companyProfiles.route('/companyProfiles/<companyProfileId>', methods=['GET'])
def get_company_profile(companyProfileId):
query = '''
SELECT companyProfileId, name, bio, industry, websiteLink
FROM companyProfiles
WHERE companyProfileId = %s
'''

cursor = db.get_db().cursor()
cursor.execute(query, (companyProfileId,))
theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response

# Advisor views all company profiles
@companyProfiles.route('/companyProfiles', methods=['GET'])
def get_all_company_profiles():
query = '''
SELECT companyProfileId, name, bio, industry, websiteLink
FROM companyProfiles
ORDER BY name
'''

cursor = db.get_db().cursor()
cursor.execute(query)
theData = cursor.fetchall()

the_response = make_response(jsonify(theData))
the_response.status_code = 200
return the_response
Loading