Changeset - cf1d1239cd55
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 7 years ago 2018-11-28 21:22:28
thomas.de_schampheleire@nokia.com
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.
1 file changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/model/notification.py
Show inline comments
 
@@ -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
 
            )
0 comments (0 inline, 0 general)