def get(self, request, start_time, end_time): if not request.user.admin_permissions.can_view_statistic(): return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') op_type_list = [ 'web-file-upload', 'web-file-download', 'sync-file-download', 'sync-file-upload', 'link-file-upload', 'link-file-download' ] init_count = [0] * 6 init_data = get_init_data(start_time, end_time, dict(list(zip(op_type_list, init_count)))) for e in get_system_traffic_by_day(start_time, end_time, get_time_offset()): dt, op_type, count = e init_data[dt].update({op_type: count}) res_data = [] for k, v in list(init_data.items()): res = {'datetime': datetime_to_isoformat_timestr(k)} res.update(v) res_data.append(res) return Response(sorted(res_data, key=lambda x: x['datetime']))
def get(self, request, start_time, end_time): op_type_list = ['web-file-upload', 'web-file-download', 'sync-file-download', 'sync-file-upload', 'link-file-upload', 'link-file-download'] init_count = [0] * 6 init_data = get_init_data(start_time, end_time, dict(zip(op_type_list, init_count))) for e in get_system_traffic_by_day(start_time, end_time, get_time_offset()): dt, op_type, count = e init_data[dt].update({op_type: count}) res_data = [] for k, v in init_data.items(): res = {'datetime': datetime_to_isoformat_timestr(k)} res.update(v) res_data.append(res) return Response(sorted(res_data, key=lambda x: x['datetime']))