Adjusted the way statistics get processed
This commit is contained in:
parent
a18f1b0fb2
commit
46194ab4fe
1 changed files with 11 additions and 36 deletions
|
@ -245,50 +245,25 @@ export const juggl = {
|
|||
});
|
||||
},
|
||||
loadDailyStatistics({ dispatch }, { date }) {
|
||||
dispatch("loadStatistics", [{ from: date, until: date }]);
|
||||
dispatch("loadStatistics", { from: date, until: date });
|
||||
},
|
||||
loadMonthlyStatistics(
|
||||
{ dispatch },
|
||||
{ startYear, startMonth, endYear, endMonth }
|
||||
) {
|
||||
var frames = [];
|
||||
|
||||
// Count all the months until end year and month
|
||||
while (
|
||||
startYear < endYear ||
|
||||
(startYear == endYear && startMonth <= endMonth)
|
||||
) {
|
||||
// Create frame
|
||||
frames.push({
|
||||
var options = {
|
||||
from: new Date(startYear, startMonth, 1),
|
||||
until: new Date(startYear, startMonth, 0) // 0 leads to the last day of the given month
|
||||
});
|
||||
until: new Date(endYear, endMonth, 0) // 0 leads to the last day of the given month
|
||||
};
|
||||
|
||||
// Count up
|
||||
if (startMonth >= 12) {
|
||||
startMonth = 1;
|
||||
startYear++;
|
||||
} else {
|
||||
startMonth++;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch("loadStatistics", frames);
|
||||
dispatch("loadStatistics", options);
|
||||
},
|
||||
async loadStatistics({ commit }, frames) {
|
||||
var statistics = [];
|
||||
|
||||
for (const frame of frames) {
|
||||
var result = Object.values(
|
||||
(await jugglService.getStatistics(frame)).data.statistics
|
||||
async loadStatistics({ commit }, options) {
|
||||
var results = Object.values(
|
||||
(await jugglService.getStatistics(options)).data.statistics
|
||||
);
|
||||
|
||||
if (result.length > 0) {
|
||||
statistics = [...statistics, ...result];
|
||||
}
|
||||
}
|
||||
|
||||
commit("setStatistics", statistics);
|
||||
commit("setStatistics", results);
|
||||
},
|
||||
loadRunningRecords({ commit, getters }) {
|
||||
return jugglService.getRunningRecords().then(r => {
|
||||
|
|
Loading…
Reference in a new issue