From 9601a37c00a48dbe857952e03bf3c25e7a4b1238 Mon Sep 17 00:00:00 2001 From: bniwredyc Date: Tue, 9 May 2023 23:52:55 +0200 Subject: [PATCH] ai test.py update --- test.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index 627cc372..b47defdf 100644 --- a/test.py +++ b/test.py @@ -1,11 +1,26 @@ from sqlalchemy import select +from sqlalchemy.orm import joinedload + from ai.preprocess import get_clear_text from base.orm import local_session -from orm import Shout +from orm import Shout, Topic if __name__ == "__main__": with local_session() as session: - q = select(Shout) - for [shout] in session.execute(q): - clear_shout_body = get_clear_text(shout.body) - print(clear_shout_body) + q = select(Shout).options( + joinedload(Shout.authors), + joinedload(Shout.topics), + ).where( + Shout.deletedAt.is_(None) + ) + + for [shout] in session.execute(q).unique(): + print(shout.topics) + # clear_shout_body = get_clear_text(shout.body) + # print(clear_shout_body) + # + + topics_q = select(Topic) + for [topic] in session.execute(topics_q): + print(topic.body) +