mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 06:43:07 +02:00
[API] Improve aggregation/users/activity
This commit is contained in:
parent
d1393d31ee
commit
7f3ff239dd
1 changed files with 5 additions and 1 deletions
|
@ -14,6 +14,10 @@ import Post from '../../../models/post';
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
module.exports = (params) => new Promise(async (res, rej) => {
|
module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
|
// Get 'limit' parameter
|
||||||
|
const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).$;
|
||||||
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
||||||
// Get 'user_id' parameter
|
// Get 'user_id' parameter
|
||||||
const [userId, userIdErr] = $(params.user_id).id().$;
|
const [userId, userIdErr] = $(params.user_id).id().$;
|
||||||
if (userIdErr) return rej('invalid user_id param');
|
if (userIdErr) return rej('invalid user_id param');
|
||||||
|
@ -85,7 +89,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
const graph = [];
|
const graph = [];
|
||||||
|
|
||||||
for (let i = 0; i < 365; i++) {
|
for (let i = 0; i < limit; i++) {
|
||||||
const day = new Date(new Date().setDate(new Date().getDate() - i));
|
const day = new Date(new Date().setDate(new Date().getDate() - i));
|
||||||
|
|
||||||
const data = datas.filter(d =>
|
const data = datas.filter(d =>
|
||||||
|
|
Loading…
Reference in a new issue