From b9957eec9ee316bce7d3d7d8c3dec54e15c46a0e Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Wed, 19 Jul 2023 22:51:23 +0800 Subject: [PATCH] Improved subjects postmigration print log --- stude/subjects/models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stude/subjects/models.py b/stude/subjects/models.py index b98fead..99d5acf 100644 --- a/stude/subjects/models.py +++ b/stude/subjects/models.py @@ -96,6 +96,7 @@ def populate_subjects(sender, **kwargs): subject_count = 0 updated_subjects = 0 ignored_subjects = 0 + existing_subjects = 0 for row in reader: if not any(row): continue @@ -132,6 +133,7 @@ def populate_subjects(sender, **kwargs): # If subject already exists with relevant info, skip over it if (Subject.objects.filter(name=subject_name, year_levels=year_level, semesters=semester).exists()): # print('Duplicate subject') + existing_subjects += 1 continue # Else if subject exists without relevant info, add relevant info @@ -162,7 +164,9 @@ def populate_subjects(sender, **kwargs): subject_count += 1 # Set the course, year level, and semester of the subject - print('Added', subject_count, 'subjects from', filename,) - print('Updated', updated_subjects, 'subjects from', filename) + print('Skipped', existing_subjects, + 'already existing subjects') + print('Added', subject_count, 'subjects') + print('Updated', updated_subjects, 'subjects') print('Ignored', ignored_subjects, - 'subjects from', filename, '\n') + 'subjects', '\n')