-
Notifications
You must be signed in to change notification settings - Fork 14
Labor attendance report 1626 #1684
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
base: development
Are you sure you want to change the base?
Changes from all commits
5905549
97fe183
4c89d93
be0b9af
eeb4674
07e2ded
ee86729
c9119da
6209cba
d68bda6
4a863e3
7652303
d37e2ae
7936d62
86fd8c6
4354374
85cedd3
240e802
5cd4859
ef2e93d
80081a2
f9749ff
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||||||
| from datetime import date, datetime,time | ||||||||||||||||
| from app import app | ||||||||||||||||
| from app.models import mainDB | ||||||||||||||||
| from app.models.celtsLabor import CeltsLabor | ||||||||||||||||
| from app.models.eventParticipant import EventParticipant | ||||||||||||||||
| from app.models.user import User | ||||||||||||||||
| from app.models.program import Program | ||||||||||||||||
|
|
@@ -225,6 +226,74 @@ def calculateRetentionRate(fallDict, springDict): | |||||||||||||||
|
|
||||||||||||||||
| return retentionDict | ||||||||||||||||
|
|
||||||||||||||||
| def laborAttendanceByTerm(term): | ||||||||||||||||
| laborQuery = ( #so that all Celts Labor students appear even if they didn't attend anything | ||||||||||||||||
| CeltsLabor | ||||||||||||||||
| .select( | ||||||||||||||||
| fn.CONCAT(User.firstName, ' ', User.lastName).alias('fullName'), | ||||||||||||||||
| User.bnumber, | ||||||||||||||||
| fn.CONCAT(User.username, '@berea.edu').alias('email'), | ||||||||||||||||
| fn.COUNT(fn.DISTINCT(Event.id)).alias('meetingsAttended') | ||||||||||||||||
| ) | ||||||||||||||||
| .join(User) | ||||||||||||||||
| .switch(CeltsLabor) | ||||||||||||||||
| .join( | ||||||||||||||||
| EventParticipant, | ||||||||||||||||
| JOIN.LEFT_OUTER, | ||||||||||||||||
| on=(CeltsLabor.user == EventParticipant.user) | ||||||||||||||||
| ) | ||||||||||||||||
| .join( | ||||||||||||||||
| Event, | ||||||||||||||||
| JOIN.LEFT_OUTER, | ||||||||||||||||
| on=( | ||||||||||||||||
| (EventParticipant.event == Event.id) & | ||||||||||||||||
| (Event.term == term) & | ||||||||||||||||
| (Event.isLaborOnly == True) & | ||||||||||||||||
| (Event.deletionDate.is_null()) & | ||||||||||||||||
| (Event.isCanceled == False) | ||||||||||||||||
| ) | ||||||||||||||||
| ) | ||||||||||||||||
| .where( | ||||||||||||||||
| (CeltsLabor.term == term) | ||||||||||||||||
| ) | ||||||||||||||||
| .group_by(CeltsLabor.user) | ||||||||||||||||
| ) | ||||||||||||||||
Arohasina marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+256
to
+260
|
||||||||||||||||
|
|
||||||||||||||||
| nonLaborQuery = ( #so that non-labor attendees who are not in CeltsLabor also appear | ||||||||||||||||
| EventParticipant | ||||||||||||||||
| .select( | ||||||||||||||||
| fn.CONCAT(User.firstName, ' ', User.lastName).alias('fullName'), | ||||||||||||||||
| User.bnumber, | ||||||||||||||||
| fn.CONCAT(User.username, '@berea.edu').alias('email'), | ||||||||||||||||
| fn.COUNT(EventParticipant.event_id).alias('meetingsAttended') | ||||||||||||||||
|
||||||||||||||||
| fn.COUNT(EventParticipant.event_id).alias('meetingsAttended') | |
| fn.COUNT(fn.DISTINCT(EventParticipant.event_id)).alias('meetingsAttended') |
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query selects non-aggregated columns (full name, bnumber, email) but only groups by EventParticipant.user. As written, it depends on MySQL's permissive GROUP BY behavior and can fail under ONLY_FULL_GROUP_BY. Group by the non-aggregated selected columns (or the underlying User fields) so the aggregation is deterministic and compatible with stricter SQL modes.
| .group_by(EventParticipant.user) | |
| .group_by( | |
| User.firstName, | |
| User.lastName, | |
| User.bnumber, | |
| User.username, | |
| ) |
Uh oh!
There was an error while loading. Please reload this page.