mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-23 17:29:05 +01:00
This commit is contained in:
parent
0da6e7a161
commit
c32954fb28
@ -79,17 +79,20 @@ export default (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch all files to calculate drive usage
|
// Calculate drive usage
|
||||||
const files = await DriveFile
|
const usage = ((await DriveFile
|
||||||
.find({ user_id: user._id }, {
|
.aggregate([
|
||||||
fields: {
|
{ $match: { user_id: user._id } },
|
||||||
datasize: true,
|
{ $project: {
|
||||||
_id: false
|
datasize: true
|
||||||
}
|
}},
|
||||||
});
|
{ $group: {
|
||||||
|
_id: null,
|
||||||
// Calculate drive usage (in byte)
|
usage: { $sum: '$datasize' }
|
||||||
const usage = files.map(file => file.datasize).reduce((x, y) => x + y, 0);
|
}}
|
||||||
|
]))[0] || {
|
||||||
|
usage: 0
|
||||||
|
}).usage;
|
||||||
|
|
||||||
log(`drive usage is ${usage}`);
|
log(`drive usage is ${usage}`);
|
||||||
|
|
||||||
|
@ -15,15 +15,20 @@ import DriveFile from '../models/drive-file';
|
|||||||
module.exports = (params, user) =>
|
module.exports = (params, user) =>
|
||||||
new Promise(async (res, rej) =>
|
new Promise(async (res, rej) =>
|
||||||
{
|
{
|
||||||
// Fetch all files to calculate drive usage
|
// Calculate drive usage
|
||||||
const files = await DriveFile
|
const usage = ((await DriveFile
|
||||||
.find({ user_id: user._id }, {
|
.aggregate([
|
||||||
datasize: true,
|
{ $match: { user_id: user._id } },
|
||||||
_id: false
|
{ $project: {
|
||||||
});
|
datasize: true
|
||||||
|
}},
|
||||||
// Calculate drive usage (in byte)
|
{ $group: {
|
||||||
const usage = files.map(file => file.datasize).reduce((x, y) => x + y, 0);
|
_id: null,
|
||||||
|
usage: { $sum: '$datasize' }
|
||||||
|
}}
|
||||||
|
]))[0] || {
|
||||||
|
usage: 0
|
||||||
|
}).usage;
|
||||||
|
|
||||||
res({
|
res({
|
||||||
capacity: user.drive_capacity,
|
capacity: user.drive_capacity,
|
||||||
|
Loading…
Reference in New Issue
Block a user