def get_time_series(self, interval, time_stats_ago=365): return set_gaps_zero(time_series( qs=self.get_graph_queryset(), date_field=self.date_field, interval=interval, aggregate=Count('id'), date_from=self.request.request_time.date() + timedelta(-time_stats_ago), date_to=self.request.request_time.date() ))
def get_time_series(self, interval, time_stats_ago=365): return set_gaps_zero( time_series(qs=self.get_graph_queryset(), date_field=self.date_field, interval=interval, aggregate=Count('id'), date_from=self.request.request_time.date() + timedelta(-time_stats_ago), date_to=self.request.request_time.date()))
def get(self, request, *args, **kwargs): if 'type' in request.GET: data_info = dict(self.data)[request.GET['type']] data = [(_('Date'), data_info['name'])] start_date, end_date, interval, aggregate = self.get_interval(request) time_series = set_gaps_zero(get_time_series( data_info['qs'], date_field=data_info['date_col'], aggregate=Count('id'), interval=interval[:-1], date_from=start_date, date_to=end_date )) data += self.acumulate(time_series, aggregate) else: data = self.data for obj in data: del obj[1]['qs'] return self.format_data(data, request.GET.get('format', 'json'))