diff --git a/README.md b/README.md index 63b4a925..f74855a3 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ Install deps first on osx ``` -brew install redis poetry nginx +brew install redis nginx brew services start redis ``` on debian/ubuntu ``` -apt install redis python-poetry nginx +apt install redis nginx ``` Then run nginx, redis and API server @@ -30,17 +30,9 @@ redis-server cp nginx.conf /usr/local/etc/nginx/. nginx -s reload -poetry install -poetry run python server.py -poetry run python server.py inbox -``` - -## Data prepare - -Also, you'll need to migrate some data - -``` -poetry run python migrate.py all +pip install -r requirements.txt +python server.py +python server.py inbox ``` # How to do an authorized request diff --git a/resolvers/reactions.py b/resolvers/reactions.py index 7041761e..dbec2fe1 100644 --- a/resolvers/reactions.py +++ b/resolvers/reactions.py @@ -105,20 +105,20 @@ async def delete_reaction(_, info, id): return {} @query.field("reactionsByShout") -def get_shout_reactions(_, info, slug)-> List[Reaction]: +def get_shout_reactions(_, info, slug): #offset = page * size #end = offset + size return ReactionsStorage.reactions_by_shout.get(slug, []) #[offset:end] @query.field("reactionsAll") -def get_all_reactions(_, info, page=1, size=10) -> List[Reaction]: +def get_all_reactions(_, info, page=1, size=10): offset = page * size end = offset + size return ReactionsStorage.reactions[offset:end] @query.field("reactionsByAuthor") -def get_reactions_by_author(_, info, slug, page=1, size=50) -> List[Reaction]: +def get_reactions_by_author(_, info, slug, page=1, size=50): offset = page * size end = offset + size return ReactionsStorage.reactions_by_author.get(slug, [])[offset:end] diff --git a/resolvers/zine.py b/resolvers/zine.py index ec6d9bbe..25913fac 100644 --- a/resolvers/zine.py +++ b/resolvers/zine.py @@ -57,9 +57,10 @@ async def get_shout_by_slug(_, info, slug): options([ selectinload(Shout.topics), selectinload(Shout.reactions), - selectinload(Shout.authors) + joinedload(Shout.authors, innerjoin=True), + selectinload(ShoutAuthor.caption) ]).\ - join([ShoutAuthor.user, ShoutAuthor.caption], ShoutAuthor.shout == slug ).\ + join(ShoutAuthor.caption.label('caption'), ShoutAuthor.shout == slug ).\ filter(Shout.slug == slug).first() if not shout: diff --git a/schema.graphql b/schema.graphql index 94eacd34..0f608c36 100644 --- a/schema.graphql +++ b/schema.graphql @@ -322,7 +322,7 @@ type Reaction { type Author { slug: String! - name: String + name: String! userpic: String caption: String # only for full shout }