From ff3a4debce85fe906bfee73dfcb3564220304fcf Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 27 Mar 2025 14:43:17 -0300 Subject: [PATCH] debug(reader.py): trying to handle main topic ids founded --- resolvers/reader.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resolvers/reader.py b/resolvers/reader.py index 79d604ca..95bc6dc8 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -253,10 +253,10 @@ def get_shouts_with_links(info, q, limit=20, offset=0): "is_main": True, } elif not main_topic: - logger.warning(f"No main_topic and no topics found for shout#{shout_id}") + logger.debug(f"No main_topic and no topics found for shout#{shout_id}") main_topic = {"id": 0, "title": "no topic", "slug": "notopic", "is_main": True} shout_dict["main_topic"] = main_topic - # logger.debug(f"Final main_topic for shout#{shout_id}: {main_topic}") + logger.debug(f"Final main_topic for shout#{shout_id}: {main_topic}") if has_field(info, "authors") and hasattr(row, "authors"): shout_dict["authors"] = ( @@ -420,6 +420,13 @@ async def load_shouts_search(_, info, text, options): ) q = q.filter(Shout.id.in_(hits_ids)) q = apply_filters(q, options) + + # added this to join topics + topic_join = aliased(ShoutTopic) + topic = aliased(Topic) + q = q.outerjoin(topic_join, topic_join.shout == Shout.id) + q = q.outerjoin(topic, topic.id == topic_join.topic) + q = apply_sorting(q, options) shouts = get_shouts_with_links(info, q, limit, offset) for shout in shouts: