Fewer queries on stats/scales + Fix

Scales:
- Fix #chunks when used with std_chunk=True (there was one too many at
  the beginning)
- Scale.end gives the end of the last chunk (instead of its start)
  So scale.begin -> scale.end gives the full range of the scale.

`kfet_day` now returns an aware datetime.

ScaleMixin:
- new method `get_by_chunks` which use only one query and ranks
  elements according to the scale. Elements are returned by a generator
  for each scale chunk (and all chunks are returned as a generator too).

ArticlesStatSales and AccountStatOperations use this new method to
avoid issuing #scale_chunks queries.

ArticleStat:
- fixed on Chrome
This commit is contained in:
Aurélien Delobelle 2017-04-12 18:03:31 +02:00
parent e97e0081d7
commit 3f4a1adbb9
4 changed files with 140 additions and 32 deletions

View file

@ -61,7 +61,7 @@
var chart = charts[i];
// format the data
var chart_data = is_time_chart ? handleTimeChart(chart.values) : dictToArray(chart.values, 1);
var chart_data = is_time_chart ? handleTimeChart(chart.values) : dictToArray(chart.values, 0);
chart_datasets.push(
{
@ -132,7 +132,7 @@
type: 'line',
options: chart_options,
data: {
labels: (data.labels || []).slice(1),
labels: data.labels || [],
datasets: chart_datasets,
}
};