Skip to content

Commit

Permalink
Updated builtin_timeseries.py to add count_documents() implementation
Browse files Browse the repository at this point in the history
Implemented code for issue e-mission#933 in e-mission-docs for adding functionality to count number of documents.
I've determined that 'key' parameter can be passed to retrieve appropriate timeseries db collection.
A query is generated with optional extra_query keys list which returns filtered data set.
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Aug 26, 2023
1 parent 94e7478 commit 3c92c4b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions emission/storage/timeseries/builtin_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,15 @@ def update_data(user_id, key, obj_id, data):
logging.debug("updating entry %s into timeseries" % new_entry)
edb.save(ts.get_timeseries_db(key), new_entry)

def count_data(self, key, extra_query_list):
"""
Returns the total number of documents for the specific key referring to a timeseries db.
Additional keys can be passed as an optional list for filtering data.
"""
logging.debug("count_data timeseries called")
created_query = self._get_query([key], extra_query_list)
result_dataset = self.get_timeseries_db(key)
total_entries = result_set.count_documents(created_query)
return total_entries


0 comments on commit 3c92c4b

Please sign in to comment.