search-resolver-fix

This commit is contained in:
Untone 2023-12-03 01:22:16 +03:00
parent 4f857e1425
commit b93d91528b
2 changed files with 12 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from orm.topic import TopicFollower
from orm.reaction import Reaction, ReactionKind from orm.reaction import Reaction, ReactionKind
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility
from orm.author import AuthorFollower, Author from orm.author import AuthorFollower, Author
from services.search import SearchService
from services.viewed import ViewedStorage from services.viewed import ViewedStorage
@ -179,6 +180,7 @@ async def load_shouts_drafts(_, info):
joinedload(Shout.topics), joinedload(Shout.topics),
) )
.filter(Shout.deleted_at.is_(None)) .filter(Shout.deleted_at.is_(None))
.filter(Shout.visibility == ShoutVisibility.AUTHORS.value)
) )
shouts = [] shouts = []
@ -249,3 +251,12 @@ async def load_shouts_feed(_, info, options):
shouts.append(shout) shouts.append(shout)
return shouts return shouts
@query.field("load_shouts_search")
async def load_shouts_search(_, _info, text, limit=50, offset=0):
if text and len(text) > 2:
return SearchService.search(text, limit, offset)
else:
return []

View File

@ -354,6 +354,7 @@ type Query {
load_shouts_by(options: LoadShoutsOptions): [Shout] load_shouts_by(options: LoadShoutsOptions): [Shout]
load_shouts_search(text: String!, limit: Int, offset: Int): [Shout] load_shouts_search(text: String!, limit: Int, offset: Int): [Shout]
load_shouts_feed(options: LoadShoutsOptions): [Shout] load_shouts_feed(options: LoadShoutsOptions): [Shout]
load_shouts_drafts: [Shout]
# topic # topic
get_topic(slug: String!): Topic get_topic(slug: String!): Topic