def _aggregate_data_for_failed_request_ratio_model(self, agg_minutes=60, start_time=None, end_time=None, ids_to_exclude=[]):
    clean_data = self._get_clean_data_collection()
    project_dict = self._get_clean_data_projection_dict()
    filter_dict_elems = [{'correctorStatus': 'done'}]
    if (len(ids_to_exclude) > 0):
        id_exclude_query = {'_id': {'$nin': ids_to_exclude}}
        filter_dict_elems.append(id_exclude_query)
    if (start_time is not None):
        start_time_query = {self._config.timestamp_field: {'$gte': start_time}}
        filter_dict_elems.append(start_time_query)
    if (end_time is not None):
        end_time_query = {self._config.timestamp_field: {'$lt': end_time}}
        filter_dict_elems.append(end_time_query)
    if (len(filter_dict_elems) == 1):
        filter_dict = filter_dict_elems[0]
    elif (len(filter_dict_elems) > 1):
        filter_dict = {'$and': filter_dict_elems}
    else:
        filter_dict = {}
    group_dict = {col: ('$%s' % col) for col in self._config.service_call_fields}
    group_dict[self._config.timestamp_field] = {'$subtract': [('$%s' % self._config.timestamp_field), {'$mod': [('$%s' % self._config.timestamp_field), ((1000 * 60) * agg_minutes)]}]}
    group_dict['succeeded'] = '$succeeded'
    res = clean_data.aggregate([{'$project': project_dict}, {'$match': filter_dict}, {'$group': {'_id': group_dict, 'count': {'$sum': 1}, 'request_ids': {'$push': '$_id'}}}], allowDiskUse=True, maxTimeMS=14400000)
    print((datetime.datetime.now().strftime('%H:%M:%s') + ' _aggregate_data_for_failed_request_ratio_model_start '))
    results = []
    for item_tmp in res:
        results.append(item_tmp)
    print((datetime.datetime.now().strftime('%H:%M:%s') + ' _aggregate_data_for_failed_request_ratio_model_end '))
    return self._generate_dataframe(results)
def _aggregate_data_for_failed_request_ratio_model(self, agg_minutes=60, start_time=None, end_time=None, ids_to_exclude=[]):
    clean_data = self._get_clean_data_collection()
    project_dict = self._get_clean_data_projection_dict()
    filter_dict_elems = [{'correctorStatus': 'done'}]
    if (len(ids_to_exclude) > 0):
        id_exclude_query = {'_id': {'$nin': ids_to_exclude}}
        filter_dict_elems.append(id_exclude_query)
    if (start_time is not None):
        start_time_query = {self._config.timestamp_field: {'$gte': start_time}}
        filter_dict_elems.append(start_time_query)
    if (end_time is not None):
        end_time_query = {self._config.timestamp_field: {'$lt': end_time}}
        filter_dict_elems.append(end_time_query)
    if (len(filter_dict_elems) == 1):
        filter_dict = filter_dict_elems[0]
    elif (len(filter_dict_elems) > 1):
        filter_dict = {'$and': filter_dict_elems}
    else:
        filter_dict = {}
    group_dict = {col: ('$%s' % col) for col in self._config.service_call_fields}
    group_dict[self._config.timestamp_field] = {'$subtract': [('$%s' % self._config.timestamp_field), {'$mod': [('$%s' % self._config.timestamp_field), ((1000 * 60) * agg_minutes)]}]}
    group_dict['succeeded'] = '$succeeded'
    res = clean_data.aggregate([{'$project': project_dict}, {'$match': filter_dict}, {'$group': {'_id': group_dict, 'count': {'$sum': 1}, 'request_ids': {'$push': '$_id'}}}], allowDiskUse=True, maxTimeMS=14400000)
    print((datetime.datetime.now().strftime('%H:%M:%s') + ' _aggregate_data_for_failed_request_ratio_model_start '))
    results = []
    for item_tmp in res:
        results.append(item_tmp)
    print((datetime.datetime.now().strftime('%H:%M:%s') + ' _aggregate_data_for_failed_request_ratio_model_end '))
    return self._generate_dataframe(results)