Skip to content

Commit

Permalink
CONCD-955 Add new column with total lifetime numbers (#2542)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasarkar authored Sep 24, 2024
1 parent beb29ac commit 1faadc1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
13 changes: 11 additions & 2 deletions concordia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,9 @@ def review_incidents(self):
user = ConcordiaUser.objects.get(id=user_id)
incident_count = user.review_incidents(recent_accepts, recent_rejects)
if incident_count > 0:
user_incident_count.append((user.id, user.username, incident_count))
user_incident_count.append(
(user.id, user.username, incident_count, user.profile.review_count)
)

return user_incident_count

Expand All @@ -881,7 +883,14 @@ def transcribe_incidents(self):
user = ConcordiaUser.objects.get(id=user_id)
incident_count = user.transcribe_incidents(transcriptions)
if incident_count > 0:
user_incident_count.append((user.id, user.username, incident_count))
user_incident_count.append(
(
user.id,
user.username,
incident_count,
user.profile.transcribe_count,
)
)

return user_incident_count

Expand Down
8 changes: 6 additions & 2 deletions concordia/templates/emails/unusual_activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h4>{{ title }}</h4>
<tr>
<th>User</th>
<th>Transc. Incidents</th>
<th>User transcriptions</th>
</tr>
{% for row in transcriptions %}
<tr>
Expand All @@ -19,6 +20,7 @@ <h4>{{ title }}</h4>
</a>
</td>
<td>{{ row.2 }}</td>
<td>{{ row.3 }}</td>
</tr>
{% empty %}
<tr><td>No transcriptions fell within the window.</td></tr>
Expand All @@ -28,8 +30,9 @@ <h4>{{ title }}</h4>
Incidents of two or more transcriptions reviewed within a single minute:
<table>
<tr>
<td>User</td>
<td>Review Incidents</td>
<th>User</th>
<th>Review Incidents</th>
<th>User reviews</th>
</tr>
{% for row in reviews %}
<tr>
Expand All @@ -39,6 +42,7 @@ <h4>{{ title }}</h4>
</a>
</td>
<td>{{ row.2 }}</td>
<td>{{ row.3 }}</td>
</tr>
{% empty %}
<tr><td>No reviews fell within the window.</td></tr>
Expand Down
4 changes: 2 additions & 2 deletions concordia/templates/emails/unusual_activity.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{ title }}
Incidents of two or more transcriptions submitted within a single minute:
{% for row in transcriptions %}
* {{ row.1 }} | {{ row.2 }}
* {{ row.1 }} | {{ row.2 }} || {{ row.3 }}
{% empty %}
No transcriptions fell within the window.
{% endfor %}
Incidents of two or more transcriptions reviewed within a single minute:
{% for row in reviews %}
{{ row.1 }} | {{ row.2 }}
{{ row.1 }} | {{ row.2 }} | {{ row.3 }}
{% empty %}
No reviews fell within the window.
{% endfor %}
6 changes: 4 additions & 2 deletions concordia/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def test_review_incidents(self):
self.transcription1.reviewed_by.id,
self.transcription1.reviewed_by.username,
1,
2,
),
)

Expand All @@ -169,6 +170,7 @@ def test_review_incidents(self):
self.transcription1.reviewed_by.id,
self.transcription1.reviewed_by.username,
2,
2,
),
)

Expand Down Expand Up @@ -203,7 +205,7 @@ def test_transcribe_incidents(self):
self.assertEqual(len(users), 1)
self.assertEqual(
users[0],
(self.transcription1.user.id, self.transcription1.user.username, 1),
(self.transcription1.user.id, self.transcription1.user.username, 1, 4),
)

create_transcription(
Expand All @@ -215,7 +217,7 @@ def test_transcribe_incidents(self):
self.assertEqual(len(users), 1)
self.assertEqual(
users[0],
(self.transcription1.user.id, self.transcription1.user.username, 2),
(self.transcription1.user.id, self.transcription1.user.username, 2, 5),
)


Expand Down

0 comments on commit 1faadc1

Please sign in to comment.