From 5c7401af470e694c59544c94b754219aacc8dda8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 9 Jan 2019 17:07:35 +0100 Subject: [PATCH] Everything but discord works fine now --- db.py | 7 ++++--- webserver.py | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db.py b/db.py index 82155ecf..0cb41a73 100644 --- a/db.py +++ b/db.py @@ -101,12 +101,13 @@ class Mini(object): def mini_get_single_from_royal(cls, session: Session, royal: "Royal"): chain = relationship_link_chain(cls, Royal) if chain is None: - chain = [] + chain = tuple() start = session.query(cls) for connection in chain: start = start.join(connection.mapper.class_) start = start.filter(Royal.id == royal.id) - return start.one() + mini = start.one() + return mini class Royal(Base, Mini): @@ -1185,7 +1186,7 @@ class Terraria13(Base, Mini): return f"" -mini_list = [Royal, Telegram, Steam, RocketLeague, Dota, LeagueOfLegends, Osu, Discord, Overwatch, Halloween, +mini_list = [Royal, Telegram, Steam, Dota, LeagueOfLegends, Osu, Discord, Overwatch, Halloween, Terraria13] diff --git a/webserver.py b/webserver.py index 49270ec2..e6c5c6c5 100644 --- a/webserver.py +++ b/webserver.py @@ -13,6 +13,7 @@ import query_discord_music import random import re import functools +from sqlalchemy.orm.collections import InstrumentedList from raven.contrib.flask import Sentry app = Flask(__name__) @@ -114,7 +115,12 @@ def page_profile(name: str): css = fl_g.session.query(db.ProfileData).filter_by(royal=user).one_or_none() mini_data = [] for game in db.mini_list: - mini_data.append(game.mini_get_single_from_royal(fl_g.session, user)) + data = game.mini_get_single_from_royal(fl_g.session, user) + # TODO: investigate on why instrumentedlists are returned + if isinstance(data, InstrumentedList): + mini_data.append(data[0]) + continue + mini_data.append(data) if css is not None: converted_bio = Markup(markdown2.markdown(css.bio.replace("<", "<"), extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"]))