|
|
@ -4,35 +4,29 @@ import { STATUS } from '../model/builtin';
|
|
|
|
import storage from '../model/storage';
|
|
|
|
import storage from '../model/storage';
|
|
|
|
|
|
|
|
|
|
|
|
export async function run(_, report) {
|
|
|
|
export async function run(_, report) {
|
|
|
|
const cursor = storage.coll.find({ path: { $regex: /^problem\//i } }).sort({ path: 1 });
|
|
|
|
let totalProblemSize = 0;
|
|
|
|
const count = await cursor.count();
|
|
|
|
const m = await storage.coll.aggregate([
|
|
|
|
report({ message: `Total ${count} files` });
|
|
|
|
{ $match: { path: { $regex: /^problem\//i } } },
|
|
|
|
let current = '';
|
|
|
|
{ $addFields: { domainId: { $arrayElemAt: [{ $split: ['$path', '/'] }, 1] } } },
|
|
|
|
let memory = 0;
|
|
|
|
{ $group: { _id: '$domainId', size: { $sum: '$size' }, count: { $sum: 1 } } },
|
|
|
|
let start = new Date().getTime();
|
|
|
|
{ $match: { size: { $gt: 10 * 1024 * 1024 } } },
|
|
|
|
// eslint-disable-next-line no-constant-condition
|
|
|
|
{ $sort: { size: -1 } },
|
|
|
|
while (true) {
|
|
|
|
]).toArray();
|
|
|
|
const doc = await cursor.next();
|
|
|
|
for (let i = 0; i < m.length; i++) {
|
|
|
|
const id = doc?.path.split('problem/')[1].split('/')[0]!;
|
|
|
|
const message = m[i]._id;
|
|
|
|
if (!current) current = id;
|
|
|
|
report({
|
|
|
|
if (!doc || current !== id) {
|
|
|
|
case: {
|
|
|
|
const end = new Date().getTime();
|
|
|
|
id: i + 1,
|
|
|
|
report({
|
|
|
|
message,
|
|
|
|
case: {
|
|
|
|
memory: Math.floor(m[i].size / 102.4) / 10,
|
|
|
|
message: current,
|
|
|
|
time: 0,
|
|
|
|
memory: Math.floor(memory / 102.4) / 10,
|
|
|
|
status: STATUS.STATUS_ACCEPTED,
|
|
|
|
time: end - start,
|
|
|
|
score: 0,
|
|
|
|
status: STATUS.STATUS_ACCEPTED,
|
|
|
|
},
|
|
|
|
score: 0,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
totalProblemSize += m[i].size;
|
|
|
|
});
|
|
|
|
|
|
|
|
start = end;
|
|
|
|
|
|
|
|
memory = 0;
|
|
|
|
|
|
|
|
current = id;
|
|
|
|
|
|
|
|
if (!doc) break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
memory += doc.size || 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
report({ message: `Problem total ${totalProblemSize / 1024 / 1024} MB` });
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|