From f7645771368af073186c4f705fdef97a61a2d018 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Thu, 17 Nov 2022 22:47:40 +0300 Subject: [PATCH] simple body title search, reacted filted fix --- .gitlab-ci.yml | 4 ++-- resolvers/zine.py | 7 +++++-- services/search.py | 10 ++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5269fd33..29cb99d0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,8 +10,8 @@ deploy: stage: deploy environment: name: production - url: https://testapi.discours.io + url: https://v2.discours.io only: - main script: - - git-push ssh://dokku@staging.discours.io:22/$APP_NAME + - git-push ssh://dokku@v2.discours.io:22/$APP_NAME diff --git a/resolvers/zine.py b/resolvers/zine.py index c782e759..ee2877d6 100644 --- a/resolvers/zine.py +++ b/resolvers/zine.py @@ -47,8 +47,11 @@ async def load_shouts_by(_, info, by, limit=50, offset=0): q = q.filter(Shout.slug == by["slug"]) else: if by.get("reacted"): - user = info.context["request"].user - q = q.filter(Reaction.createdBy == user.slug) + try: + user = info.context["request"].user + q = q.filter(Reaction.createdBy == user.slug) + except Exception: + pass if by.get("visibility"): q = q.filter(or_( Shout.visibility.ilike(f"%{by.get('visibility')}%"), diff --git a/services/search.py b/services/search.py index e11a7372..3384a6ab 100644 --- a/services/search.py +++ b/services/search.py @@ -1,5 +1,7 @@ import asyncio + from orm.shout import Shout +from resolvers.zine import load_shouts_by class SearchService: @@ -13,6 +15,10 @@ class SearchService: SearchService.cache = {} @staticmethod - async def search(text) -> [Shout]: + async def search(text, limit, offset) -> [Shout]: async with SearchService.lock: - return [] # TODO: implement getting shouts list + by = { + "title": text, + "body": text + } + return await load_shouts_by(None, None, by, limit, offset)