-
Notifications
You must be signed in to change notification settings - Fork 14
1660 CCE minor students not showing #1664
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
Changes from all commits
c856c78
321f9b9
26d5fa2
afafe59
d12c524
519ce53
db749fb
f241e33
3aa0245
210a6e9
2ae342b
0621b36
c1eddbc
77c6d50
9f4cb9a
5f5b1cc
cbdda37
22a694d
1788137
69c9f80
07b58f0
7c66c9d
cdb2513
c687bfe
0ad9ddb
f33d9ba
ac5e855
37a9768
7e5aee8
7a1f4e2
bd4da1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,10 @@ def getMinorProgress(): | |
| .join(IndividualRequirement, on=(User.username == IndividualRequirement.username)) | ||
| .join(CertificationRequirement, on=(IndividualRequirement.requirement_id == CertificationRequirement.id)) | ||
| .switch(User).join(CCEMinorProposal, JOIN.LEFT_OUTER, on= (User.username == CCEMinorProposal.student)) | ||
| .where(CertificationRequirement.certification_id == Certification.CCE) | ||
| .where( | ||
| (CertificationRequirement.certification_id == Certification.CCE) & | ||
| (User.declaredMinor == True) | ||
| ) | ||
| .group_by(User.firstName, User.lastName, User.username) | ||
| .order_by(SQL("engagementCount").desc()) | ||
| ) | ||
|
|
@@ -184,13 +187,71 @@ def declareMinorInterest(username): | |
|
|
||
| def getDeclaredMinorStudents(): | ||
| """ | ||
| Get a list of the students who have declared minor | ||
| This function retrieves a list of students who have declared the CCE minor along with their engagement progress. | ||
| It returns a list of dictionaries containing student information and their engagement details and adds students who have no requirements but have declared the minor with 0 engagements. | ||
| """ | ||
| declaredStudents = User.select().where(User.isStudent & User.declaredMinor) | ||
| summerEngagementCount = fn.COUNT( | ||
| fn.DISTINCT( | ||
| Case( | ||
| None, | ||
| [(CCEMinorProposal.proposalType == "Summer Experience", CCEMinorProposal.id)], | ||
| None | ||
| ) | ||
| ) | ||
| ).alias("summerEngagementCount") | ||
|
|
||
| # this returns the count of distinct engagements that have a certification requirement id. | ||
| # this is important because our join clause specifically joins individualrequirements with the certifications that match to CCE | ||
| # while leaving the rest as null | ||
| cceEngagementCount = fn.COUNT( | ||
| fn.DISTINCT( | ||
| Case( | ||
| None, | ||
| [(CertificationRequirement.id.is_null(False), IndividualRequirement.id)], | ||
| None | ||
| ) | ||
| ) | ||
| ).alias("allEngagementCount") | ||
|
|
||
| q = ( | ||
| User | ||
| .select( | ||
| User, | ||
| cceEngagementCount, | ||
| summerEngagementCount, | ||
| fn.IF(fn.COUNT(fn.DISTINCT(CCEMinorProposal.id)) > 0, True, False).alias("hasCCEMinorProposal"), | ||
| ) | ||
| .join(IndividualRequirement, JOIN.LEFT_OUTER, on=(User.username == IndividualRequirement.username)) | ||
| .join(CertificationRequirement, JOIN.LEFT_OUTER, on=( | ||
| (IndividualRequirement.requirement_id == CertificationRequirement.id) & | ||
| (CertificationRequirement.certification_id == Certification.CCE) # only cce minor certs are populated with non-null | ||
| )) | ||
| .switch(User) | ||
| .join(CCEMinorProposal, JOIN.LEFT_OUTER, on=(User.username == CCEMinorProposal.student)) | ||
| .where( | ||
| (User.declaredMinor == True) & | ||
| (User.isStudent == True) | ||
| ) | ||
| .group_by(User.username) | ||
| .order_by(SQL("allEngagementCount").desc()) | ||
| ) | ||
|
|
||
| interestedStudentList = [model_to_dict(student) for student in declaredStudents] | ||
| result = [] | ||
| for s in q: | ||
| engagementCount = int(s.allEngagementCount or 0) | ||
|
Kafui123 marked this conversation as resolved.
|
||
| result.append({ | ||
| "firstName": s.firstName, | ||
| "lastName": s.lastName, | ||
| "username": s.username, | ||
| "B-Number": s.bnumber, | ||
| "email": s.email, | ||
| "hasGraduated": s.hasGraduated, | ||
| "engagementCount": engagementCount, | ||
| "hasCCEMinorProposal": bool(s.hasCCEMinorProposal), | ||
| "hasSummer": "Completed" if (s.summerEngagementCount and int(s.summerEngagementCount) > 0) else "Incomplete", | ||
| }) | ||
|
Comment on lines
+239
to
+252
|
||
|
|
||
| return interestedStudentList | ||
| return result | ||
|
Comment on lines
188
to
+254
|
||
|
|
||
| def getCourseInformation(id): | ||
| """ | ||
|
|
@@ -269,6 +330,7 @@ def setCommunityEngagementForUser(action, engagementData, currentUser): | |
| "requirement": requirement.get(), | ||
| "addedBy": currentUser, | ||
| }) | ||
|
|
||
| # Thrown if there are no available engagement requirements left. Handled elsewhere. | ||
| except DoesNotExist as e: | ||
| raise e | ||
|
|
@@ -279,6 +341,7 @@ def setCommunityEngagementForUser(action, engagementData, currentUser): | |
| IndividualRequirement.username == engagementData['username'], | ||
| IndividualRequirement.term == engagementData['term'] | ||
| ).execute() | ||
|
|
||
| else: | ||
| raise Exception(f"Invalid action '{action}' sent to setCommunityEngagementForUser") | ||
|
|
||
|
|
@@ -374,6 +437,7 @@ def saveSummerExperience(username, summerExperience, currentUser): | |
| "requirement": requirement.get(), | ||
| "addedBy": currentUser, | ||
| }) | ||
|
|
||
| return "" | ||
|
|
||
| def getSummerExperience(username): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.