diff --git a/oml/user/models.py b/oml/user/models.py index e0b2a82..9640c0a 100644 --- a/oml/user/models.py +++ b/oml/user/models.py @@ -161,13 +161,9 @@ class User(db.Model): if not was_peering: Changelog.record(state.user(), 'addpeer', self.id, self.nickname) if not 'index' in self.info: - qs = User.query.filter_by(peered=True) - if qs.count(): - self.info['index'] = max([ - u.info.get('index', -1) for u in qs - ]) + 1 - else: - self.info['index'] = 1 + self.info['index'] = max([ + u.info.get('index', -1) for u in User.query.filter_by(peered=True) + ] + [0]) + 1 self.peered = True self.save() if self.id in state.removepeer: