query-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m33s

This commit is contained in:
Untone 2024-10-14 09:23:11 +03:00
parent 5dc61dc397
commit 503e859b5c
4 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,8 @@
[0.4.4]
- followers_stat removed
- sqlite3 support added
- rating_stat and commented_stat fix
[0.4.3] [0.4.3]
- cache reimplemented - cache reimplemented
- load shouts queries unified - load shouts queries unified

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "core" name = "core"
version = "0.4.3" version = "0.4.4"
description = "core module for discours.io" description = "core module for discours.io"
authors = ["discoursio devteam"] authors = ["discoursio devteam"]
license = "MIT" license = "MIT"

View File

@ -88,7 +88,7 @@ def query_shouts(slug=None):
func.count(aliased_reaction.id) func.count(aliased_reaction.id)
.filter(aliased_reaction.kind == ReactionKind.COMMENT.value) .filter(aliased_reaction.kind == ReactionKind.COMMENT.value)
.label("comments_stat"), .label("comments_stat"),
func.count(ShoutReactionsFollower.follower).label("followers_stat"), # func.count(ShoutReactionsFollower.follower).label("followers_stat"),
func.sum( func.sum(
case( case(
(aliased_reaction.kind == ReactionKind.LIKE.value, 1), (aliased_reaction.kind == ReactionKind.LIKE.value, 1),
@ -177,12 +177,22 @@ def get_shouts_with_stats(q, limit, offset=0, author_id=None):
# Формирование списка публикаций с их данными # Формирование списка публикаций с их данными
shouts = [] shouts = []
for shout, comments_stat, followers_stat, rating_stat, last_reacted_at, authors, topics, main_topic_slug in results:
for [
shout,
comments_stat,
# followers_stat,
rating_stat,
last_reacted_at,
authors,
topics,
main_topic_slug,
] in results:
shout.authors = parse_aggregated_string(authors, Author) shout.authors = parse_aggregated_string(authors, Author)
shout.topics = parse_aggregated_string(topics, Topic) shout.topics = parse_aggregated_string(topics, Topic)
shout.stat = { shout.stat = {
"viewed": ViewedStorage.get_shout(shout.id), "viewed": ViewedStorage.get_shout(shout.id),
"followed": followers_stat or 0, # "followed": followers_stat or 0,
"rating": rating_stat or 0, "rating": rating_stat or 0,
"commented": comments_stat or 0, "commented": comments_stat or 0,
"last_reacted_at": last_reacted_at, "last_reacted_at": last_reacted_at,
@ -288,7 +298,7 @@ async def get_shout(_, info, slug: str):
[ [
shout, shout,
commented_stat, commented_stat,
followers_stat, # followers_stat,
rating_stat, rating_stat,
last_reaction_at, last_reaction_at,
authors, authors,

View File

@ -95,7 +95,7 @@ type Stat {
rating: Int rating: Int
commented: Int commented: Int
viewed: Int viewed: Int
followed: Int # followed: Int
last_reacted_at: Int last_reacted_at: Int
} }