From 33b1b1288b8e7d79ca84c66be5768af8c82a3aa2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 23 Aug 2021 21:10:49 +0200 Subject: [PATCH] fdfd --- files/classes/user.py | 4 +--- files/routes/login.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 7e2839636..6da1fe0fc 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -423,15 +423,13 @@ class User(Base, Stndrd, Age_times): User.id != self.id ).order_by(User.username.asc()).all() + data = [x for x in data] output = [] for x in data: user = x[0] user._is_manual = x[1].is_manual output.append(user) - for alt in output: - output += alt.alts - return output def alts_threaded(self, db): diff --git a/files/routes/login.py b/files/routes/login.py index bcd1f2e56..6c45b2458 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -40,10 +40,22 @@ def check_for_alts(current_id): if not check1 and not check2: try: - new_alt = Alt(user1=past_id, - user2=current_id) + new_alt = Alt(user1=past_id, user2=current_id) g.db.add(new_alt) - + otheralts = g.db.query(Alt).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all() + print(otheralts) + for a in otheralts: + try: + new_alt = Alt(user1=a.user1, user2=past_id) + g.db.add(new_alt) + g.db.flush() + new_alt = Alt(user1=a.user1, user2=current_id) + g.db.add(new_alt) + g.db.flush() + except Exception as e: + g.db.rollback() + print(e) + continue except BaseException: pass