Added statistics API

This commit is contained in:
Maximilian Giller 2021-07-28 00:00:10 +02:00
parent 2770f0e8d8
commit d435d5db04

View file

@ -37,6 +37,27 @@ export const jugglService = {
});
},
getStatistics(options = {}) {
if (options.from === undefined) {
options.from = new Date();
}
if (options.until === undefined) {
options.until = new Date();
}
return apiService
.post("/getStats.php", {
from_date: helperService.toISODateOnly(options.from),
until_date: helperService.toISODateOnly(options.until)
})
.then(r => {
return {
data: { statistics: processVisibility(r.data.stats) },
msg: ""
};
});
},
getRecord(recordId) {
return apiService
.post("/getRecord.php", {
@ -257,23 +278,20 @@ function processRecords(data) {
}
function processTags(tags) {
Object.values(tags).forEach(tag => {
if (tag.visible === "1") {
tag.visible = true;
} else {
tag.visible = false;
}
});
return tags;
return processVisibility(tags);
}
function processProjects(projects) {
Object.values(projects).forEach(pro => {
if (pro.visible === "1") {
pro.visible = true;
return processVisibility(projects);
}
function processVisibility(items) {
Object.values(items).forEach(item => {
if (item.visible === "1") {
item.visible = true;
} else {
pro.visible = false;
item.visible = false;
}
});
return projects;
return items;
}