core/test.py

27 lines
728 B
Python
Raw Normal View History

2023-05-09 21:41:13 +00:00
from sqlalchemy import select
2023-05-09 21:52:55 +00:00
from sqlalchemy.orm import joinedload
2023-05-09 21:41:13 +00:00
from ai.preprocess import get_clear_text
from base.orm import local_session
2023-05-09 21:52:55 +00:00
from orm import Shout, Topic
2023-05-09 21:41:13 +00:00
if __name__ == "__main__":
with local_session() as session:
2023-05-09 21:52:55 +00:00
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)