Skip to content

Commit 52ad0ef

Browse files
committed
Reverse default action: _is_digest is included in uniqueness check
1 parent a65df9b commit 52ad0ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

osf/management/commands/migrate_notifications_verification.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def add_arguments(self, parser):
2323
parser.add_argument('--frequencies', action='store_true', help='Check message_frequency values for invalid ones')
2424
parser.add_argument('--counts', action='store_true', help='Compare legacy M2M total with migrated count')
2525
parser.add_argument('--distribution', action='store_true', help='Print breakdown summary')
26-
parser.add_argument('--unique-digest', action='store_true', default=False, help='Used along with --duplicates to include _is_digest field in unique_together')
26+
parser.add_argument('--exclude-is-digest', action='store_true', default=False, help='Used along with --duplicates to exclude _is_digest field in unique_together')
2727
parser.add_argument('--output-size', type=int, default=10, help='Used along with other options to set the number of found duplicates for output')
2828

2929
def handle(self, *args, **options):
@@ -40,19 +40,20 @@ def handle(self, *args, **options):
4040

4141
# 1. Detect duplicates
4242
if run_all or 'duplicates' in flags:
43-
print(f'1) Checking duplicate NotificationSubscription entries (unique-digest:{options['unique_digest']})...')
44-
if options['unique_digest']:
43+
action_word = 'excludes' if options['exclude_is_digest'] else 'includes'
44+
print(f'1) Checking duplicate NotificationSubscription entries (unique_together {action_word} _is_digest)...')
45+
if options['exclude_is_digest']:
4546
duplicates = (
4647
NotificationSubscription.objects.values(
47-
'user_id', 'content_type_id', 'object_id', 'notification_type_id', '_is_digest',
48+
'user_id', 'content_type_id', 'object_id', 'notification_type_id',
4849
)
4950
.annotate(count=Count('id'))
5051
.filter(count__gt=1)
5152
)
5253
else:
5354
duplicates = (
5455
NotificationSubscription.objects.values(
55-
'user_id', 'content_type_id', 'object_id', 'notification_type_id',
56+
'user_id', 'content_type_id', 'object_id', 'notification_type_id', '_is_digest',
5657
)
5758
.annotate(count=Count('id'))
5859
.filter(count__gt=1)

0 commit comments

Comments
 (0)