dummy search query interface
This commit is contained in:
parent
661bbcd1de
commit
c85672b209
|
@ -83,6 +83,28 @@ async def get_shout_by_slug(_, info, slug):
|
|||
return shout
|
||||
|
||||
|
||||
@query.field("searchQuery")
|
||||
async def get_search_results(_, info, query, page, size):
|
||||
# TODO: remove the copy of searchByTopics
|
||||
# with search ranking query
|
||||
page = page - 1
|
||||
with local_session() as session:
|
||||
shouts = (
|
||||
session.query(Shout)
|
||||
.join(ShoutTopic)
|
||||
.where(and_(ShoutTopic.topic.in_(query), bool(Shout.publishedAt)))
|
||||
.order_by(desc(Shout.publishedAt))
|
||||
.limit(size)
|
||||
.offset(page * size)
|
||||
)
|
||||
|
||||
for s in shouts:
|
||||
for a in s.authors:
|
||||
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
|
||||
s.stat.search = 1 # FIXME
|
||||
return shouts
|
||||
|
||||
|
||||
@query.field("shoutsByTopics")
|
||||
async def shouts_by_topics(_, info, slugs, page, size):
|
||||
page = page - 1
|
||||
|
|
|
@ -259,6 +259,9 @@ type Query {
|
|||
# communities
|
||||
getCommunity(slug: String): Community!
|
||||
getCommunities: [Community]! # all
|
||||
|
||||
# search
|
||||
searchQuery(q: String, page: Int, size: Int): Shout[]
|
||||
}
|
||||
|
||||
############################################ Subscription
|
||||
|
@ -423,6 +426,7 @@ type Stat {
|
|||
reacted: Int
|
||||
rating: Int
|
||||
commented: Int
|
||||
ranking: Int
|
||||
}
|
||||
|
||||
type Community {
|
||||
|
|
Loading…
Reference in New Issue
Block a user