Skip to content

Commit

Permalink
Merge pull request #101 from opportunity-hack/develop
Browse files Browse the repository at this point in the history
/volunteer/track - update to show committeed and active time tracking
  • Loading branch information
gregv authored Oct 15, 2024
2 parents dd5758e + 7633108 commit c7e9032
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
22 changes: 21 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,25 @@
"develop"
],
"terminal.integrated.defaultProfile.osx": "x86 bash",
"python.defaultInterpreterPath": "/opt/miniconda3/envs/ohack/bin/python3.9"
"python.defaultInterpreterPath": "/opt/miniconda3/envs/ohack/bin/python3.9",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#93e6fc",
"activityBar.background": "#93e6fc",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#fa45d4",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#93e6fc",
"statusBar.background": "#61dafb",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#2fcefa",
"statusBarItem.remoteBackground": "#61dafb",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#61dafb",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#61dafb99",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#61dafb"
}
2 changes: 1 addition & 1 deletion api/messages/messages_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ def get_problem_statement_list_old():
logger.debug(results)
return { "problem_statements": results }

@cached(cache=TTLCache(maxsize=100, ttl=600))
@cached(cache=TTLCache(maxsize=100, ttl=10))
@limits(calls=100, period=ONE_MINUTE)
def get_github_profile(github_username):
logger.debug(f"Getting Github Profile for {github_username}")
Expand Down
11 changes: 6 additions & 5 deletions api/users/users_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ def save_volunteering_time():
@auth.require_user
def get_volunteering_time():
# Get url params
start_date = request.args.get('start_date')
end_date = request.args.get('end_date')
start_date = request.args.get('startDate')
end_date = request.args.get('endDate')

if auth_user and auth_user.user_id:
volunteering, total = users_service.get_volunteering_time(auth_user.user_id, start_date, end_date)
allVolunteering, totalActiveHours, totalCommitmentHours = users_service.get_volunteering_time(auth_user.user_id, start_date, end_date)
return {
"totalHours": total,
"volunteering": volunteering
"totalActiveHours": totalActiveHours,
"totalCommitmentHours": totalCommitmentHours,
"allVolunteering": allVolunteering
}
else:
return None
Expand Down
26 changes: 21 additions & 5 deletions services/users_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,31 @@ def get_volunteering_time(propel_id, start_date, end_date):
return

# Filter the volunteering data
volunteering = []
volunteeringActiveTime = []
for v in user.volunteering:
if "finalHours" in v:
if start_date is not None and end_date is not None:
if v["timestamp"] >= start_date and v["timestamp"] <= end_date:
volunteering.append(v)
volunteeringActiveTime.append(v)
else:
volunteering.append(v)
volunteeringActiveTime.append(v)

volunteeringCommittmentTime = []
for v in user.volunteering:
if "commitmentHours" in v:
if start_date is not None and end_date is not None:
if v["timestamp"] >= start_date and v["timestamp"] <= end_date:
volunteeringCommittmentTime.append(v)
else:
volunteeringCommittmentTime.append(v)

total = sum([v["finalHours"] for v in volunteering])
totalActiveHours = sum([v["finalHours"] for v in volunteeringActiveTime])
totalCommitmentHours = sum([v["commitmentHours"] for v in volunteeringCommittmentTime])

# Merge volunteeringActiveTime and volunteeringCommittmentTime
# This is a bit of a hack but it is easier to do it this way than to try to do it in the frontend
allVolunteering = volunteeringActiveTime + volunteeringCommittmentTime

logger.debug(f"allVolunteering: {allVolunteering} || volunteeringActiveTime: {volunteeringActiveTime} volunteeringCommittmentTime: {volunteeringCommittmentTime} Total Active Hours: {totalActiveHours} Total Commitment Hours: {totalCommitmentHours}")

return volunteering, total
return allVolunteering, totalActiveHours, totalCommitmentHours

0 comments on commit c7e9032

Please sign in to comment.