Skip to content
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

CONCD-824 changing output of method #2478

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions concordia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ def resource_file_upload_path(instance, filename):

class ConcordiaUserManager(BaseUserManager):
def review_incidents(self):
user_incident_count = {}
user_incident_count = []

for user in self.get_queryset().filter(is_superuser=False, is_staff=False):
incident_count = user.review_incidents()
if incident_count > 0:
user_incident_count[user.id] = incident_count
user_incident_count.append((user.id, user.username, incident_count))

return user_incident_count

def transcribe_incidents(self):
user_incident_count = {}
user_incident_count = []

for user in self.get_queryset().filter(is_superuser=False, is_staff=False):
incident_count = user.transcribe_incidents()
if incident_count > 0:
user_incident_count[user.id] = incident_count
user_incident_count.append((user.id, user.username, incident_count))

return user_incident_count

Expand Down
8 changes: 0 additions & 8 deletions concordia/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,14 +1044,6 @@ def fix_storage_images(campaign_slug=None, asset_start_id=None):
logger.debug("%s / %s (%s%%)", count, full_count, str(count / full_count * 100))


def transcribing_too_quickly():
return Transcription.objects.transcribing_too_quickly()


def reviewing_too_quickly():
return Transcription.objects.reviewing_too_quickly()


@celery_app.task(ignore_result=True)
def clear_sessions():
# This clears expired Django sessions in the database
Expand Down
28 changes: 24 additions & 4 deletions concordia/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ def test_review_incidents(self):
)
users = ConcordiaUser.objects.review_incidents()
self.assertEqual(len(users), 1)
self.assertEqual(users[self.transcription1.reviewed_by.id], 1)
self.assertEqual(
users[0],
(
self.transcription1.reviewed_by.id,
self.transcription1.reviewed_by.username,
1,
),
)

create_transcription(
asset=self.transcription1.asset,
Expand All @@ -93,7 +100,14 @@ def test_review_incidents(self):
)
users = ConcordiaUser.objects.review_incidents()
self.assertEqual(len(users), 1)
self.assertEqual(users[self.transcription1.reviewed_by.id], 2)
self.assertEqual(
users[0],
(
self.transcription1.reviewed_by.id,
self.transcription1.reviewed_by.username,
2,
),
)

def test_transcribe_incidents(self):
self.transcription1.submitted = timezone.now()
Expand Down Expand Up @@ -124,7 +138,10 @@ def test_transcribe_incidents(self):
)
users = ConcordiaUser.objects.transcribe_incidents()
self.assertEqual(len(users), 1)
self.assertEqual(users[self.transcription1.user.id], 1)
self.assertEqual(
users[0],
(self.transcription1.user.id, self.transcription1.user.username, 1),
)

create_transcription(
asset=self.transcription1.asset,
Expand All @@ -133,7 +150,10 @@ def test_transcribe_incidents(self):
)
users = ConcordiaUser.objects.transcribe_incidents()
self.assertEqual(len(users), 1)
self.assertEqual(users[self.transcription1.user.id], 2)
self.assertEqual(
users[0],
(self.transcription1.user.id, self.transcription1.user.username, 2),
)


class AssetTestCase(CreateTestUsers, TestCase):
Expand Down