Skip to content

Labor attendance report 1626#1684

Open
Arohasina wants to merge 11 commits intodevelopmentfrom
Labor_Attendance_report_1626
Open

Labor attendance report 1626#1684
Arohasina wants to merge 11 commits intodevelopmentfrom
Labor_Attendance_report_1626

Conversation

@Arohasina
Copy link
Contributor

@Arohasina Arohasina commented Feb 25, 2026

Issue Description

Fixes #1626

  • We should have a sheet in the Reports downloads that shows labor attendance for the academic year. The report should have a list of labor students and the number of labor meetings that they attended for each term in the academic year.

Changes

  • Implemented laborAttendanceByTerm(academicYear) function to query labor students and count their meeting attendance by term
  • Added "Labor Attendance By Term" sheet to the spreadsheet generation in createSpreadsheet()
  • added the test function test_laborAttendanceByTerm in test_spreadsheet.py

This is how the spreadsheet looks like:
image

Testing

  • run database/reset_database.sh test and then tests/run_tests.sh or if you want to test the laborAttendanceByTerm function specifically, you can run pytest tests/code/test_spreadsheet.py::test_laborAttendanceByTerm -v
  • after it passed, run database/reset_database.sh from-backup and then flask run
  • Once you are in the Celts app, go to event list choose Spring 2025, and then choose a couple of events there, such as these events
image
  • And for each, click on the event, turn on the toggle "This event is for labor only" , and then click "save"
image
  • Then go to admin --> report --> select academic year 2024 - 2025 --> download the spreadsheet, open it, and you should see a sheet called "Labor Attendance By Term" with the reporting.

Copilot AI review requested due to automatic review settings February 25, 2026 22:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements a labor attendance report feature that tracks labor student participation in labor-only meetings across terms within an academic year. The implementation adds a new sheet to the downloadable reports spreadsheet showing each labor student's meeting attendance count per term.

Changes:

  • Added laborAttendanceByTerm() function to query and aggregate labor meeting attendance by student and term
  • Integrated the new "Labor Attendance By Term" sheet into the spreadsheet generation workflow
  • Added comprehensive integration test coverage for the new functionality

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
app/logic/volunteerSpreadsheet.py Implements laborAttendanceByTerm function (lines 228-249) to query labor students and count their meeting attendance, and integrates it into createSpreadsheet (line 298)
tests/code/test_spreadsheet.py Adds test_laborAttendanceByTerm integration test (lines 686-724) covering empty results and attendance counting scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 26, 2026 20:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Arohasina and others added 2 commits February 26, 2026 15:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +228 to +242
def laborAttendanceByTerm(academicYear):
"""Get labor students and their meeting attendance count for each term"""
base = getBaseQuery(academicYear)

query = (base.select(
fn.CONCAT(User.firstName, ' ', User.lastName).alias('fullName'),
User.bnumber,
fn.CONCAT(EventParticipant.user_id, '@berea.edu').alias('email'),
Term.description,
fn.COUNT(EventParticipant.event_id).alias('meetingsAttended'),
)
.where(Event.isLaborOnly == True)
.group_by(EventParticipant.user_id, Term.description)
.order_by(User.lastName, User.firstName, Term.description)
)
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

laborAttendanceByTerm is currently counting attendees of labor-only events, but it doesn’t restrict the population to CELTS labor students (e.g., records in CeltsLabor) and it will omit labor students who have 0 meeting attendance. This doesn’t match the issue requirement of listing labor students for the academic year with per-term attendance counts. Consider driving the report off CeltsLabor (per term / academic year) and LEFT JOINing labor-only EventParticipant rows so labor students with zero attendance still appear with a 0 count, and non-labor attendees are excluded.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 26, 2026 20:37
@github-actions
Copy link

View Code Coverage

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +690 to 693
EventParticipant.create(event=fixture_info["event1"], user=fixture_info['user1'], hoursEarned=1)
EventParticipant.create(event=fixture_info["event2"], user=fixture_info['user1'], hoursEarned=1)
EventParticipant.create(event=fixture_info["event1"], user=fixture_info['user2'], hoursEarned=1)

Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test creates duplicate EventParticipant records for the same user-event combinations (user1 on event1 already exists from fixture line 68, and user2 on event1 already exists from fixture line 69). However, the production code in app/logic/participants.py (lines 52, 69-70) and app/logic/volunteers.py (lines 38-48) prevents such duplicates by checking if a participant already exists before creating a new record. This test should either remove the existing participants from the fixture for these events, or create participations for different events to avoid testing an impossible scenario.

Suggested change
EventParticipant.create(event=fixture_info["event1"], user=fixture_info['user1'], hoursEarned=1)
EventParticipant.create(event=fixture_info["event2"], user=fixture_info['user1'], hoursEarned=1)
EventParticipant.create(event=fixture_info["event1"], user=fixture_info['user2'], hoursEarned=1)
# Create separate labor events for this test to avoid duplicating existing participations
labor_event1 = Event.create(
name="Labor Attendance Test Event 1",
term=fixture_info["term1"],
program=fixture_info["program1"],
startDate=date(2023, 9, 1),
isCanceled=False,
deletionDate=None,
isService=False,
)
labor_event2 = Event.create(
name="Labor Attendance Test Event 2",
term=fixture_info["term1"],
program=fixture_info["program1"],
startDate=date(2023, 10, 1),
isCanceled=False,
deletionDate=None,
isService=False,
)
EventParticipant.create(event=labor_event1, user=fixture_info["user1"], hoursEarned=1)
EventParticipant.create(event=labor_event2, user=fixture_info["user1"], hoursEarned=1)
EventParticipant.create(event=labor_event1, user=fixture_info["user2"], hoursEarned=1)

Copilot uses AI. Check for mistakes.
Comment on lines +698 to +699
assert ("John Doe", "B774377", "doej@berea.edu", "Fall 2023", 3) in results
assert ("Jane Doe", "B888828", "doej2@berea.edu", "Fall 2023", 2) in results No newline at end of file
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test assertions expect user1 to have attended 3 meetings and user2 to have attended 2 meetings. However, if the duplicate EventParticipant creation issue (lines 690-692) is fixed, the expected values should be 2 meetings for user1 (event1 and event2) and 1 meeting for user2 (event1), assuming the fixture participants are removed or the test creates participations for different events.

Suggested change
assert ("John Doe", "B774377", "doej@berea.edu", "Fall 2023", 3) in results
assert ("Jane Doe", "B888828", "doej2@berea.edu", "Fall 2023", 2) in results
assert ("John Doe", "B774377", "doej@berea.edu", "Fall 2023", 2) in results
assert ("Jane Doe", "B888828", "doej2@berea.edu", "Fall 2023", 1) in results

Copilot uses AI. Check for mistakes.
Comment on lines +689 to +699
def test_laborAttendanceByTerm(fixture_info):
EventParticipant.create(event=fixture_info["event1"], user=fixture_info['user1'], hoursEarned=1)
EventParticipant.create(event=fixture_info["event2"], user=fixture_info['user1'], hoursEarned=1)
EventParticipant.create(event=fixture_info["event1"], user=fixture_info['user2'], hoursEarned=1)

columns, results = laborAttendanceByTerm("2023-2024-test")
assert columns == ("Full Name", "B-Number", "Email", "Term", "Meetings Attended")

assert len(results) == 2
assert ("John Doe", "B774377", "doej@berea.edu", "Fall 2023", 3) in results
assert ("Jane Doe", "B888828", "doej2@berea.edu", "Fall 2023", 2) in results No newline at end of file
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test only covers participation in Fall 2023 labor events, but the academic year '2023-2024-test' also includes Spring 2024 (term3). Consider adding a labor event in Spring 2024 and creating participations for it to verify that the function correctly groups attendance by multiple terms and that students appear in multiple rows (one per term they participated in).

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +36
isService=True,
isLaborOnly=True
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace after the comma on these lines. Consider removing it for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
isService=True,
isLaborOnly=True
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace after the comma on these lines. Consider removing it for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 26, 2026 20:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Labor Attendance report

3 participants