-
Notifications
You must be signed in to change notification settings - Fork 83
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
Slip Calculator Jobs for Assignment and Course #1148
base: master
Are you sure you want to change the base?
Changes from 1 commit
b7d01a5
9f0fe75
d6cbe8c
5d5e6a9
82c50fa
a10376a
8ef25c9
28d916d
4073666
ddd9e40
0fab8ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
|
||
|
||
from server import jobs | ||
from server.models import Assignment | ||
from server.constants import TIMESCALES | ||
from datetime import datetime as dt | ||
from math import ceil | ||
|
||
timescales = {'days':86400, 'hours':3600, 'minutes':60} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should go in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this originally, but realized if I would then have to use the dictionary keys to fill in the form options, which wouldn't have a guaranteed ordering. Now that I've thought about it, I think I'll just use an OrderedDict to preserve the ordering of the keys for display on the form. |
||
|
||
def timediff(created, deadline, timescale): | ||
secs_over = (created - deadline).total_seconds() | ||
return ceil(secs_over / timescales[timescale.lower()]) | ||
|
||
@jobs.background_job | ||
def calculate_slips(): | ||
def calculate_slips(assign_id, timescale): | ||
logger = jobs.get_job_logger() | ||
logger.info('hello world!') | ||
job = jobs.get_current_job() | ||
|
||
logger.info('Calculating slip {}...'.format(timescale)) | ||
assignment = Assignment.query.get(assign_id) | ||
subms = assignment.course_submissions(include_empty=False) | ||
deadline = assignment.due_date | ||
for subm in subms: | ||
email = subm['user']['email'] | ||
created = subm['backup']['created'] | ||
logger.info('{} {}' | ||
.format(email, timediff(created, deadline, timescale))) | ||
|
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.
I suggest keeping the timescale lowercase, so it matches up with the TIMESCALES enum. And you won't need the
.lower()
on L16 in slips.py