events-trigger-query-fix
All checks were successful
Deploy on push / deploy (push) Successful in 25s

This commit is contained in:
2024-02-26 00:06:37 +03:00
parent b02b8276a6
commit 5ca072dfaa
6 changed files with 29 additions and 10 deletions

View File

@@ -60,7 +60,7 @@ class Base(declarative_base()):
make_searchable(Base.metadata)
Base.metadata.create_all(engine)
Base.metadata.create_all(bind=engine)
# Функция для вывода полного трейсбека при предупреждениях

View File

@@ -35,13 +35,14 @@ def after_shouts_update(mapper, connection, shout: Shout):
Shout.id == shout.id,
ShoutAuthor.shout == Shout.id,
ShoutAuthor.author == Author.id,
),
)
),
)
)
# Основной запрос с использованием объединения и подзапроса exists
authors_query = (
select(Author)
.select_from(Author)
.join(ShoutAuthor, Author.id == ShoutAuthor.author)
.where(ShoutAuthor.shout == shout.id)
.union(select(Author).where(exists(subquery)))
@@ -56,6 +57,7 @@ def after_reaction_insert(mapper, connection, reaction: Reaction):
author_subquery = select(Author).where(Author.id == reaction.created_by)
replied_author_subquery = (
select(Author)
.select_from(Author)
.join(Reaction, Author.id == Reaction.created_by)
.where(Reaction.id == reaction.reply_to)
)

View File

@@ -34,7 +34,7 @@ class WebhookEndpoint(HTTPEndpoint):
)
if author:
slug = slug + '-' + user_id.split('-').pop()
await create_author(user_id, slug, name)
create_author(user_id, slug, name)
return JSONResponse({'status': 'success'})
except Exception as e: