fix(api): sort images count and types count
This commit is contained in:
parent
606821a2c0
commit
a06d5ffaed
1 changed files with 4 additions and 6 deletions
|
@ -43,21 +43,19 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
by: ['mimetype'],
|
by: ['mimetype'],
|
||||||
_count: {
|
_count: {
|
||||||
mimetype: true
|
mimetype: true
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const types_count = [];
|
const types_count = [];
|
||||||
for (let i = 0, L = typesCount.length; i !== L; ++i) {
|
for (let i = 0, L = typesCount.length; i !== L; ++i) types_count.push({ mimetype: typesCount[i].mimetype, count: typesCount[i]._count.mimetype });
|
||||||
types_count.push({ mimetype: typesCount[i].mimetype, count: typesCount[i]._count.mimetype });
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
size: bytesToRead(size),
|
size: bytesToRead(size),
|
||||||
size_num: size,
|
size_num: size,
|
||||||
count,
|
count,
|
||||||
count_by_user,
|
count_by_user: count_by_user.sort((a,b) => b.count-a.count),
|
||||||
count_users,
|
count_users,
|
||||||
views_count: (viewsCount[0]?._sum?.views ?? 0),
|
views_count: (viewsCount[0]?._sum?.views ?? 0),
|
||||||
types_count
|
types_count: types_count.sort((a,b) => b.count-a.count)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue