Skip to content

Commit 6c73770

Browse files
Update count_entity_total method following the review
1 parent 867ec60 commit 6c73770

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,31 @@ Count the number of inserted entities. This method corresponds to a [POST reques
271271
from pyslicer import SlicingDice
272272
client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
273273

274-
tables = {
275-
'tables': [
276-
'default'
277-
]
274+
print client.count_entity_total()
275+
```
276+
277+
#### Output example
278+
279+
```json
280+
{
281+
"status": "success",
282+
"result": {
283+
"total": 42
284+
},
285+
"took": 0.103
278286
}
287+
```
288+
289+
### `count_entity_total(tables)`
290+
Count the total number of inserted entities in the given tables. This method corresponds to a [POST request at /query/count/entity/total](http://panel.slicingdice.com/docs/#api-details-api-endpoints-get-query-count-entity-total).
291+
292+
#### Request example
293+
294+
```python
295+
from pyslicer import SlicingDice
296+
client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
297+
298+
tables = ['default']
279299

280300
print client.count_entity_total(tables)
281301
```

pyslicer/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,21 +213,22 @@ def count_entity(self, query):
213213
url = base_url + URLResources.QUERY_COUNT_ENTITY
214214
return self._count_query_wrapper(url, query)
215215

216-
def count_entity_total(self, tables=None):
216+
def count_entity_total(self, tables=[]):
217217
"""Make a count entity total query
218218
219219
Keyword arguments:
220220
tables -- A dictionary containing the tables in which
221221
the total query will be performed
222222
"""
223-
if tables is None:
224-
tables = {}
223+
query = {
224+
'tables': tables
225+
}
225226
base_url = self._wrapper_test()
226227
url = base_url + URLResources.QUERY_COUNT_ENTITY_TOTAL
227228
return self._make_request(
228229
url=url,
229230
req_type="post",
230-
json_data=ujson.dumps(tables),
231+
json_data=ujson.dumps(query),
231232
key_level=0)
232233

233234
def count_event(self, query):

0 commit comments

Comments
 (0)