def _load_data(form_model, manager, questionnaire_code, request): header_list = helper.get_headers(form_model.fields) aggregation_type_list = json.loads(request.POST.get("aggregation-types")) start_time = helper.get_formatted_time_string(request.POST.get("start_time").strip() + START_OF_DAY) end_time = helper.get_formatted_time_string(request.POST.get("end_time").strip() + END_OF_DAY) aggregates = helper.get_aggregate_list(header_list[1:], aggregation_type_list) aggregates = [aggregate_module.aggregation_factory("latest", form_model.fields[0].name)] + aggregates data_dictionary = aggregate_module.aggregate_by_form_code_python(manager, questionnaire_code, aggregates=aggregates, starttime=start_time, endtime=end_time) return data_dictionary
def _get_submissions(manager,questionnaire_code, request,paginate=True): request_bag = request.GET start_time = request_bag.get("start_time") or "" end_time = request_bag.get("end_time") or "" start_time_epoch = convert_to_epoch(helper.get_formatted_time_string(start_time.strip() + START_OF_DAY)) end_time_epoch = convert_to_epoch(helper.get_formatted_time_string(end_time.strip() + END_OF_DAY)) if paginate: current_page = int(request_bag.get('page_number') or 1) count, results = _load_submissions_for_page(manager,current_page, questionnaire_code, start_time_epoch,end_time_epoch) else: count, results = _load_all_submissions(manager,questionnaire_code,start_time_epoch,end_time_epoch) error_message = "No submissions present for this project" if not count else None return count,results,error_message
def _load_data(form_model, manager, questionnaire_code, request): header_list = helper.get_headers(form_model.fields) aggregation_type_list = json.loads(request.POST.get("aggregation-types")) start_time = helper.get_formatted_time_string( request.POST.get("start_time").strip() + START_OF_DAY) end_time = helper.get_formatted_time_string( request.POST.get("end_time").strip() + END_OF_DAY) aggregates = helper.get_aggregate_list(header_list[1:], aggregation_type_list) aggregates = [ aggregate_module.aggregation_factory("latest", form_model.fields[0].name) ] + aggregates data_dictionary = aggregate_module.aggregate_by_form_code_python( manager, questionnaire_code, aggregates=aggregates, starttime=start_time, endtime=end_time) return data_dictionary
def _get_submissions(manager, questionnaire_code, request, paginate=True): request_bag = request.GET start_time = request_bag.get("start_time") or "" end_time = request_bag.get("end_time") or "" start_time_epoch = convert_to_epoch( helper.get_formatted_time_string(start_time.strip() + START_OF_DAY)) end_time_epoch = convert_to_epoch( helper.get_formatted_time_string(end_time.strip() + END_OF_DAY)) if paginate: current_page = int(request_bag.get('page_number') or 1) count, results = _load_submissions_for_page(manager, current_page, questionnaire_code, start_time_epoch, end_time_epoch) else: count, results = _load_all_submissions(manager, questionnaire_code, start_time_epoch, end_time_epoch) error_message = "No submissions present for this project" if not count else None return count, results, error_message