Skip to content

Commit 94308db

Browse files
committed
Adds 'count' as an argument in aggregations API
Fixes syntax errors in API
1 parent 634b845 commit 94308db

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

loklak.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def suggest(self, query=None, count=None, order=None, orderby=None,since=None, u
215215
return json.dumps(return_to_user)
216216

217217
def aggregations(self, query=None, since=None, until=None,
218-
fields=None, limit=None):
218+
fields=None, limit=6, count=0):
219219
"""Gives the aggregations of the application"""
220220
aggregations_application = 'api/search.json'
221221
url_to_give = self.baseUrl+aggregations_application
@@ -224,6 +224,7 @@ def aggregations(self, query=None, since=None, until=None,
224224
self.until = until
225225
self.fields = fields
226226
self.limit = limit
227+
self.count = count
227228
if query:
228229
params = {}
229230
params['query'] = self.query
@@ -232,16 +233,12 @@ def aggregations(self, query=None, since=None, until=None,
232233
if until:
233234
params['query'] = params['query']+' until:'+self.until
234235
if fields:
235-
field_string = ''
236-
for i in self.fields:
237-
field_string += i + ','
238-
params['fields'] = field_string
239-
if limit:
240-
params['limit'] = self.limit
241-
if limit is None:
242-
limit = 6
243-
params['limit'] = self.limit
244-
params['count'] = 0
236+
if isinstance(fields, list):
237+
params['fields'] = ','.join(self.fields)
238+
else:
239+
params['fields'] = self.fields
240+
241+
params['count'] = self.count
245242
params['source'] = 'cache'
246243
return_to_user = requests.get(url_to_give, params=params)
247244
if return_to_user.status_code == 200:

0 commit comments

Comments
 (0)