Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
submitReport: Capture if the report was originally flagged for review.
Browse files Browse the repository at this point in the history
Because the Journeyman role is randomly chosen for review 15% of the
time, and we have no way to log changes to the "pending review" flag,
it is not possible to report on if a particular report was
_originally_ flagged for review, as that is not predictable from the
original `api_log`, nor accurate from the current `report`.

Add an immutable-in-the-UI column for if the report was originally
chosen for review.  We may have better solutions in the
future (e.g. using revision objects) but this is a quick and dirty
stopgap.

A stopgap fix for #274.
  • Loading branch information
alexmv committed Apr 12, 2021
1 parent ebb459e commit f981b67
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions vaccinate/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def submit_report(request, on_request_logged):
# is_pending_review
if report_data["is_pending_review"] or user_should_have_reports_reviewed(reporter):
kwargs["is_pending_review"] = True
kwargs["originally_pending_review"] = True
if bool(request.GET.get("test")) and request.GET.get("fake_timestamp"):
fake_timestamp = parser.parse(request.GET["fake_timestamp"])
if fake_timestamp.tzinfo is None:
Expand Down
1 change: 1 addition & 0 deletions vaccinate/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ class ReportAdmin(DynamicListDisplayMixin, admin.ModelAdmin):
readonly_fields = (
"created_at",
"created_at_utc",
"originally_pending_review",
"public_id",
"airtable_id",
"airtable_json",
Expand Down
21 changes: 21 additions & 0 deletions vaccinate/core/migrations/0076_report_originally_pending_review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.1.8 on 2021-04-12 07:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0075_various_model_field_options"),
]

operations = [
migrations.AddField(
model_name="report",
name="originally_pending_review",
field=models.BooleanField(
default=False,
help_text="Reports that were originally flagged as pending review",
),
),
]
4 changes: 4 additions & 0 deletions vaccinate/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ class ReportSource(models.TextChoices):
is_pending_review = models.BooleanField(
default=False, help_text="Reports that are pending review by our QA team"
)
originally_pending_review = models.BooleanField(
default=False,
help_text="Reports that were originally flagged as pending review",
)
soft_deleted = models.BooleanField(
default=False,
help_text="we never delete rows from this table; all deletes are soft",
Expand Down
5 changes: 3 additions & 2 deletions vaccinate/core/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def test_custom_csv_export_for_reports(
report_source="ca",
appointment_tag=web,
is_pending_review=True,
originally_pending_review=True,
)
plus_65 = AvailabilityTag.objects.get(slug="vaccinating_65_plus")
plus_50 = AvailabilityTag.objects.get(slug="vaccinating_50_plus")
Expand All @@ -337,8 +338,8 @@ def test_custom_csv_export_for_reports(
csv_bytes = b"".join(chunk for chunk in response.streaming_content)
csv_string = csv_bytes.decode("utf-8")
assert csv_string == (
"id,location_id,location,is_pending_review,soft_deleted,soft_deleted_because,report_source,appointment_tag_id,appointment_tag,appointment_details,public_notes,internal_notes,reported_by_id,reported_by,created_at,call_request_id,call_request,airtable_id,airtable_json,public_id,availability_tags\r\n"
'{},{},Location 1,True,False,,ca,3,web,,,,{},auth0:reporter,{},,,,,{},"Vaccinating 65+, Vaccinating 50+"\r\n'.format(
"id,location_id,location,is_pending_review,originally_pending_review,soft_deleted,soft_deleted_because,report_source,appointment_tag_id,appointment_tag,appointment_details,public_notes,internal_notes,reported_by_id,reported_by,created_at,call_request_id,call_request,airtable_id,airtable_json,public_id,availability_tags\r\n"
'{},{},Location 1,True,True,False,,ca,3,web,,,,{},auth0:reporter,{},,,,,{},"Vaccinating 65+, Vaccinating 50+"\r\n'.format(
report.id,
report.location_id,
reporter.id,
Expand Down

0 comments on commit f981b67

Please sign in to comment.