adjust dashboard

This commit is contained in:
Emily
2024-11-13 15:44:20 +01:00
parent 2929b229c4
commit 9de299d841
19 changed files with 254 additions and 65 deletions

View File

@@ -0,0 +1,36 @@
import { EventModel } from "@schema/metrics/EventSchema";
import { SessionModel } from "@schema/metrics/SessionSchema";
import { VisitModel } from "@schema/metrics/VisitSchema";
import { Types } from "mongoose";
import { getRequestData } from "~/server/utils/getRequestData";
export default defineEventHandler(async event => {
const data = await getRequestData(event, { requireSchema: false });
if (!data) return;
const { project_id } = data;
taskDeleteAll(project_id);
return { ok: true }
});
async function taskDeleteAll(project_id: Types.ObjectId) {
console.log('Deletation all started');
const start = Date.now();
await VisitModel.deleteMany({ project_id });
await SessionModel.deleteMany({ project_id });
await EventModel.deleteMany({ project_id });
const s = (Date.now() - start) / 1000;
console.log(`Deletation all done in ${s.toFixed(2)} seconds`);
}