Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/notifications/web/notification.py

Issue 29570562: Issue 5827 - Assign new groups even if prior groups are present (Closed)
Patch Set: Removed return to make in-place editing more apparent Created Oct. 10, 2017, 2:46 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sitescripts/notifications/test/notification.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/notifications/web/notification.py
diff --git a/sitescripts/notifications/web/notification.py b/sitescripts/notifications/web/notification.py
index 918df55d2202e0e1125efebb9b994aa79aa13f2e..745a085988507f0e377a52232663e6dba3dc826a 100644
--- a/sitescripts/notifications/web/notification.py
+++ b/sitescripts/notifications/web/notification.py
@@ -34,13 +34,14 @@ def _determine_groups(version, notifications):
return groups
-def _assign_groups(notifications):
- groups = []
+def _assign_groups(groups, notifications):
selection = random.random()
start = 0
for notification in notifications:
if 'variants' not in notification:
continue
+ if notification['id'] in [g['id'] for g in groups]:
+ continue
group = {'id': notification['id'], 'variant': 0}
groups.append(group)
for i, variant in enumerate(notification['variants']):
@@ -51,7 +52,6 @@ def _assign_groups(notifications):
if selected:
group['variant'] = i + 1
break
- return groups
def _get_active_variant(notifications, groups):
@@ -111,8 +111,7 @@ def notification(environ, start_response):
notifications = load_notifications()
groups = _determine_groups(version, notifications)
notifications = [x for x in notifications if not x.get('inactive', False)]
- if not groups:
- groups = _assign_groups(notifications)
+ _assign_groups(groups, notifications)
response = _create_response(notifications, groups)
response_headers = [('Content-Type', 'application/json; charset=utf-8'),
('ABP-Notification-Version', response['version'])]
« no previous file with comments | « sitescripts/notifications/test/notification.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld