Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions app/logic/transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

def getProgramTranscript(username):
"""
Returns a dictionary with programs as keys and a list of service events and hours earned as values for the given user.
Returns a dictionary with programs as keys and a list of service or bonner events and hours earned as values for the given user.
"""
# Add up hours earned in a term for each program they've participated in

EventData = (Event.select(Event, fn.SUM(EventParticipant.hoursEarned).alias("hoursEarned"))
.join(EventParticipant)
.join(EventParticipant).switch()
.join(Program)
.where(EventParticipant.user == username,
Event.isService == True,
Event.isService | Program.isBonnerScholars,
Event.deletionDate == None,
Event.isCanceled == False)
.group_by(Event.program, Event.term)
Expand Down
9 changes: 6 additions & 3 deletions tests/code/test_transcripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def setup():
isPrerequisiteForProgram = 0,
isTraining = 0,
isService = 0,
isCanceled = 0,
startDate = "2021-12-12",
recurringId = None,
program= 5)
Expand Down Expand Up @@ -167,14 +168,16 @@ def testingProgram():
username = "namet"
adminName = "ramsayb2"
programDict = getProgramTranscript(username)
emptyProgramDict = getProgramTranscript(adminName)
# check that bonners events are caught

# check that bonners events are included
checkingProgram = Program.get_by_id(5)

assert not emptyProgramDict
assert programDict
assert checkingProgram in [t for t in programDict]

emptyProgramDict = getProgramTranscript(adminName)
assert not emptyProgramDict

@pytest.mark.integration
def testingTotalHours():

Expand Down