diff --git a/src/services/juggl.service.js b/src/services/juggl.service.js index b505c3a..b85bced 100644 --- a/src/services/juggl.service.js +++ b/src/services/juggl.service.js @@ -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; }