[PATCH 1 of 9] model: notification: don't round-trip via list if you want a set
Thomas De Schampheleire
patrickdepinguin at gmail.com
Thu Dec 6 08:14:21 UTC 2018
# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1543436548 -3600
# Wed Nov 28 21:22:28 2018 +0100
# Node ID d0eaee2ca6b205ad58b6e46723252e3e57bfa31c
# Parent 2c54a82aeaed569ef27f7813d9537d4f1adcfb32
model: notification: don't round-trip via list if you want a set
'create' in NotificationModel starts from an empty list, appends entries to
it, then converts it to a set.
You could equally start with a set and add to it, avoiding the final
conversion.
diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py
--- a/kallithea/model/notification.py
+++ b/kallithea/model/notification.py
@@ -68,16 +68,15 @@ class NotificationModel(object):
created_by_obj = User.guess_instance(created_by)
- recipients_objs = []
+ recipients_objs = set()
if recipients:
for u in recipients:
obj = User.guess_instance(u)
if obj is not None:
- recipients_objs.append(obj)
+ recipients_objs.add(obj)
else:
# TODO: inform user that requested operation couldn't be completed
log.error('cannot email unknown user %r', u)
- recipients_objs = set(recipients_objs)
log.debug('sending notifications %s to %s',
type_, recipients_objs
)
More information about the kallithea-general
mailing list