schema-fix
This commit is contained in:
parent
7d5dc8b8cd
commit
c150d28447
|
@ -1,5 +1,7 @@
|
||||||
[0.2.14]
|
[0.2.14]
|
||||||
- schema: some fixes from migrator
|
- schema: some fixes from migrator
|
||||||
|
- schema: .days -> .time_ago
|
||||||
|
- schema: excludeLayout + layout in filters -> layouts
|
||||||
- services: db access simpler, no contextmanager
|
- services: db access simpler, no contextmanager
|
||||||
- services: removed Base.create() method
|
- services: removed Base.create() method
|
||||||
- services: rediscache updated
|
- services: rediscache updated
|
||||||
|
|
|
@ -15,9 +15,7 @@ def add_stat_columns(q):
|
||||||
aliased_reaction = aliased(Reaction)
|
aliased_reaction = aliased(Reaction)
|
||||||
q = q.outerjoin(aliased_reaction).add_columns(
|
q = q.outerjoin(aliased_reaction).add_columns(
|
||||||
func.sum(aliased_reaction.id).label("reacted_stat"),
|
func.sum(aliased_reaction.id).label("reacted_stat"),
|
||||||
func.sum(
|
func.sum(case((aliased_reaction.kind == ReactionKind.COMMENT, 1), else_=0)).label("commented_stat"),
|
||||||
case((aliased_reaction.kind == ReactionKind.COMMENT, 1), else_=0)
|
|
||||||
).label("commented_stat"),
|
|
||||||
func.sum(
|
func.sum(
|
||||||
case(
|
case(
|
||||||
# do not count comments' reactions
|
# do not count comments' reactions
|
||||||
|
@ -54,8 +52,8 @@ def apply_filters(q, filters, author_id=None):
|
||||||
if v == "community":
|
if v == "community":
|
||||||
q = q.filter(Shout.visibility.in_(["public", "community"]))
|
q = q.filter(Shout.visibility.in_(["public", "community"]))
|
||||||
|
|
||||||
if filters.get("layout"):
|
if filters.get("layouts"):
|
||||||
q = q.filter(Shout.layout == filters.get("layout"))
|
q = q.filter(Shout.layout.in_(filters.get("layouts")))
|
||||||
if filters.get("author"):
|
if filters.get("author"):
|
||||||
q = q.filter(Shout.authors.any(slug=filters.get("author")))
|
q = q.filter(Shout.authors.any(slug=filters.get("author")))
|
||||||
if filters.get("topic"):
|
if filters.get("topic"):
|
||||||
|
@ -104,9 +102,7 @@ async def load_shout(_, _info, slug=None, shout_id=None):
|
||||||
"rating": rating_stat,
|
"rating": rating_stat,
|
||||||
}
|
}
|
||||||
|
|
||||||
for author_caption in (
|
for author_caption in session.query(ShoutAuthor).join(Shout).where(Shout.slug == slug):
|
||||||
session.query(ShoutAuthor).join(Shout).where(Shout.slug == slug)
|
|
||||||
):
|
|
||||||
for author in shout.authors:
|
for author in shout.authors:
|
||||||
if author.id == author_caption.author:
|
if author.id == author_caption.author:
|
||||||
author.caption = author_caption.caption
|
author.caption = author_caption.caption
|
||||||
|
@ -154,18 +150,11 @@ async def load_shouts_by(_, info, options):
|
||||||
|
|
||||||
order_by = options.get("order_by", Shout.published_at)
|
order_by = options.get("order_by", Shout.published_at)
|
||||||
|
|
||||||
query_order_by = (
|
query_order_by = desc(order_by) if options.get("order_by_desc", True) else asc(order_by)
|
||||||
desc(order_by) if options.get("order_by_desc", True) else asc(order_by)
|
|
||||||
)
|
|
||||||
offset = options.get("offset", 0)
|
offset = options.get("offset", 0)
|
||||||
limit = options.get("limit", 10)
|
limit = options.get("limit", 10)
|
||||||
|
|
||||||
q = (
|
q = q.group_by(Shout.id).order_by(nulls_last(query_order_by)).limit(limit).offset(offset)
|
||||||
q.group_by(Shout.id)
|
|
||||||
.order_by(nulls_last(query_order_by))
|
|
||||||
.limit(limit)
|
|
||||||
.offset(offset)
|
|
||||||
)
|
|
||||||
|
|
||||||
shouts = []
|
shouts = []
|
||||||
shouts_map = {}
|
shouts_map = {}
|
||||||
|
@ -201,10 +190,7 @@ async def get_my_feed(_, info, options):
|
||||||
select(Shout.id)
|
select(Shout.id)
|
||||||
.where(Shout.id == ShoutAuthor.shout)
|
.where(Shout.id == ShoutAuthor.shout)
|
||||||
.where(Shout.id == ShoutTopic.shout)
|
.where(Shout.id == ShoutTopic.shout)
|
||||||
.where(
|
.where((ShoutAuthor.author.in_(author_followed_authors)) | (ShoutTopic.topic.in_(author_followed_topics)))
|
||||||
(ShoutAuthor.author.in_(author_followed_authors))
|
|
||||||
| (ShoutTopic.topic.in_(author_followed_topics))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
q = (
|
q = (
|
||||||
|
@ -227,18 +213,11 @@ async def get_my_feed(_, info, options):
|
||||||
|
|
||||||
order_by = options.get("order_by", Shout.published_at)
|
order_by = options.get("order_by", Shout.published_at)
|
||||||
|
|
||||||
query_order_by = (
|
query_order_by = desc(order_by) if options.get("order_by_desc", True) else asc(order_by)
|
||||||
desc(order_by) if options.get("order_by_desc", True) else asc(order_by)
|
|
||||||
)
|
|
||||||
offset = options.get("offset", 0)
|
offset = options.get("offset", 0)
|
||||||
limit = options.get("limit", 10)
|
limit = options.get("limit", 10)
|
||||||
|
|
||||||
q = (
|
q = q.group_by(Shout.id).order_by(nulls_last(query_order_by)).limit(limit).offset(offset)
|
||||||
q.group_by(Shout.id)
|
|
||||||
.order_by(nulls_last(query_order_by))
|
|
||||||
.limit(limit)
|
|
||||||
.offset(offset)
|
|
||||||
)
|
|
||||||
|
|
||||||
shouts = []
|
shouts = []
|
||||||
for [
|
for [
|
||||||
|
|
|
@ -212,7 +212,7 @@ input ReactionInput {
|
||||||
shout: Int!
|
shout: Int!
|
||||||
range: String
|
range: String
|
||||||
body: String
|
body: String
|
||||||
replyTo: Int
|
reply_to: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
input AuthorsBy {
|
input AuthorsBy {
|
||||||
|
@ -222,7 +222,7 @@ input AuthorsBy {
|
||||||
name: String
|
name: String
|
||||||
topic: String
|
topic: String
|
||||||
order: String
|
order: String
|
||||||
days: Int
|
time_ago: Int
|
||||||
stat: String
|
stat: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,9 +234,9 @@ input ShoutsFilterBy {
|
||||||
topics: [String]
|
topics: [String]
|
||||||
author: String
|
author: String
|
||||||
authors: [String]
|
authors: [String]
|
||||||
layout: String
|
layouts: [String]
|
||||||
visibility: String
|
visibility: String
|
||||||
days: Int
|
time_ago: Int
|
||||||
stat: String
|
stat: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,9 +245,9 @@ input LoadShoutsFilters {
|
||||||
body: String
|
body: String
|
||||||
topic: String
|
topic: String
|
||||||
author: String
|
author: String
|
||||||
layout: String
|
layouts: [String]
|
||||||
visibility: String
|
visibility: String
|
||||||
days: Int
|
time_ago: Int
|
||||||
reacted: Boolean
|
reacted: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ input ReactionBy {
|
||||||
comment: Boolean
|
comment: Boolean
|
||||||
topic: String
|
topic: String
|
||||||
created_by: Int
|
created_by: Int
|
||||||
days: Int
|
time_ago: Int
|
||||||
sort: String
|
sort: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user