Skip to content

Commit

Permalink
Add author query param
Browse files Browse the repository at this point in the history
  • Loading branch information
malor committed Jun 24, 2018
1 parent 6f15be0 commit 10dd98f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions xsnippet/api/resources/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ async def get(self, conf):
# actual snippets to be returned
current_page = await services.Snippet().get(
title=title, tag=tag, syntax=syntax,
author=self.request.GET.get('author'),
# read one more to know if there is next page
limit=limit + 1,
marker=marker,
Expand Down
7 changes: 5 additions & 2 deletions xsnippet/api/services/snippet.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ async def update(self, snippet):
async def replace(self, snippet):
return await self.update(self._normalize(snippet))

async def get(self, *, title=None, tag=None, syntax=None, limit=100,
marker=None, direction='forward'):
async def get(self, *, title=None, tag=None, syntax=None,
author=None,
limit=100, marker=None, direction='forward'):
condition = {}

sort = self._pagination[direction]['sort']
Expand All @@ -108,6 +109,8 @@ async def get(self, *, title=None, tag=None, syntax=None, limit=100,
condition['tags'] = tag
if syntax is not None:
condition['syntax'] = syntax
if author is not None:
condition['author'] = syntax

if marker:
specimen = await self.db.snippets.find_one({'_id': marker})
Expand Down

0 comments on commit 10dd98f

Please sign in to comment.