-
Notifications
You must be signed in to change notification settings - Fork 4
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
2990 - stuck files notification #3195
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3195 +/- ##
========================================
Coverage 92.66% 92.66%
========================================
Files 47 47
Lines 1009 1009
Branches 169 169
========================================
Hits 935 935
Misses 42 42
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
|
<p>The system has detected stuck <b>{{ section }}</b> data submitted by <b>{{ stt }}</b> in <b>{{ program_type }}</b> for Fiscal Year <b>{{ fiscal_year }}</b> that was submitted on <b>{{ submission_date }}</b>.</p> | ||
|
||
<p> | ||
<a class="button" href="https://tdp-frontend-a11y.app.cloud.gov/" style="background-color:#336a90;border-radius:4px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:18px;font-weight:bold;line-height:60px;text-align:center;text-decoration:none;width: auto; padding-left: 24px; padding-right: 24px;-webkit-text-size-adjust:none;"> |
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.
Does the link to a11y environment need to be a variable?
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 deleted this whole template since it wasn't used
@shared_task | ||
def notify_stuck_files(): | ||
"""Find files stuck in 'Pending' and notify SysAdmins.""" | ||
recipients = User.objects.filter( |
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.
A minor nitpick, would it make sense to first check the stuck_files count before compiling the recipients list? It's minor but if we're not going to send an email, we don't need to do those actions.
stuck_files = get_stuck_files()
if stuck_files.count() > 0:
recipients = <...>
send_stuck_file_email(...)
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.
addressed
<td style="padding: 4px; border-style: solid; border-color: #000000; border-width: 1px;">{{ file.section }}</td> | ||
<td style="padding: 4px; border-style: solid; border-color: #000000; border-width: 1px;">{{ file.fiscal_year }}</td> | ||
<td style="padding: 4px; border-style: solid; border-color: #000000; border-width: 1px;">{{ file.created_at }} {{ file.created_time_ago }}</td> | ||
<td style="padding: 4px; border-style: solid; border-color: #000000; border-width: 1px;"><a href="">View in Admin Console</a></td> |
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.
Missing variable/link in href=""
?
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.
addressed
) | ||
|
||
stuck_files = get_stuck_files() | ||
assert stuck_files.count() == 0 |
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.
Should we have more asserts between each DataFile creation so that it is clear and debuggable which scenario failed?
# reparse submissions past the timeout, where the reparse did not complete | ||
Q( | ||
reparse_count__gt=0, | ||
reparse_meta_models__timeout_at__lte=datetime.now(tz=timezone.utc), |
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.
Instead of datetime
can we use Django's builtin timezone
? That way we can guarantee the same timezone since Django should be managing it.
|
||
|
||
def _time_ago(hours=0, minutes=0, seconds=0): | ||
return datetime.now(tz=timezone.utc) - timedelta(hours=hours, minutes=minutes, seconds=seconds) |
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.
Should use Django timezone here too if possible.
@jtimpe some unit tests are failing on this branch since the reparsing work was merged in. |
53999bb
to
e1a1f55
Compare
@ADPennington should be fixed! |
@jtimpe @victoriaatraft -- quick question -- was the design mockup here intended for this ticket or a follow-on? |
@@ -206,6 +207,10 @@ def submitted_by(self): | |||
"""Return the author as a string for this data file.""" | |||
return self.user.get_full_name() | |||
|
|||
def admin_link(self): | |||
"""Return a link to the admin console for this file.""" | |||
return f"{settings.FRONTEND_BASE_URL}/admin/data_files/datafile/?id={self.pk}" |
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.
you shouldn't need to hardcode the whole URL, you should either use reverse form django or reverse_actions from DRF as stated here: https://www.django-rest-framework.org/api-guide/viewsets/#reversing-action-urls
@ADPennington it was, but per this comment i modified the template to display a list of stuck files rather than a singular. |
ahh thank you! Appreciate the reference @jtimpe |
testing update:
|
Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com>
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.
Summary of Changes
Pull request closes #2990
How to Test
SENDGRID_API_KEY
env var is set, reach out if you need a valid keyOFA System Admin
shell_plus
, change thecreated_at
to >1hr ago.shell_plus
, change thetimeout_at
to some time in the past. Changefinished
andsuccess
toFalse
.docker compose exec web python manage.py find_pending_submissions
.Try a lot of combinations. If you can get it to fire in real life stuck-file scenarios, that's a plus.
Example of email
Deliverables
More details on how deliverables herein are assessed included here.
Deliverable 1: Accepted Features
Checklist of ACs:
lfrohlich
and/oradpennington
confirmed that ACs are met.Deliverable 2: Tested Code
CodeCov Report
comment in PR)CodeCov Report
comment in PR)Deliverable 3: Properly Styled Code
Deliverable 4: Accessible
iamjolly
andttran-hub
using Accessibility Insights reveal any errors introduced in this PR?Deliverable 5: Deployed
Deliverable 6: Documented
Deliverable 7: Secure
Deliverable 8: User Research
Research product(s) clearly articulate(s):