def _get_objects_and_count_of_occurrence_single_db(self, database, object_path, unwind=False, match=None): if self.match and database == self.db.file_objects: # filtered live query on file objects aggregation_pipeline = self._get_file_object_filter_aggregation_pipeline( pipeline_group={ '_id': object_path, 'count': { '$sum': 1 } }, pipeline_match=match, sort=True, additional_projection={object_path.replace('$', ''): 1}, unwind=object_path if unwind else None) tmp = database.aggregate(aggregation_pipeline) else: tmp = get_objects_and_count_of_occurrence(database, object_path, unwind=unwind, match=merge_dict( match, self.match)) chart_list = self._convert_dict_list_to_list(tmp) return self._filter_sanitzized_objects(chart_list)
def _get_time_stats(self): projection = { 'month': { '$month': '$release_date' }, 'year': { '$year': '$release_date' } } query = get_objects_and_count_of_occurrence(self.db.firmwares, projection, match=self.match) histogram_data = self._build_stats_entry_from_date_query(query) return {'date_histogram_data': histogram_data}