diff --git a/src/api/routes/users/#user_id/delete.ts b/src/api/routes/users/#user_id/delete.ts
index 277aeb38..7c39e2b7 100644
--- a/src/api/routes/users/#user_id/delete.ts
+++ b/src/api/routes/users/#user_id/delete.ts
@@ -17,7 +17,21 @@
*/
import { route } from "@spacebar/api";
-import { Channel, ChannelDeleteEvent, ChannelRecipientRemoveEvent, emitEvent, Emoji, Guild, InstanceBan, Member, Recipient, Sticker, User, UserDeleteEvent } from "@spacebar/util";
+import {
+ Channel,
+ ChannelDeleteEvent,
+ ChannelRecipientRemoveEvent,
+ emitEvent,
+ Emoji,
+ Guild,
+ InstanceBan,
+ Member,
+ Recipient,
+ Sticker,
+ Stopwatch,
+ User,
+ UserDeleteEvent,
+} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { ChannelType, InstanceUserDeleteSchema, PrivateUserProjection } from "@spacebar/schemas";
import { Not } from "typeorm";
@@ -40,6 +54,7 @@ router.post(
},
}),
async (req: Request, res: Response) => {
+ const sw = Stopwatch.startNew();
const body = req.body as InstanceUserDeleteSchema | undefined;
const user = await User.findOneOrFail({
where: { id: req.params.user_id },
@@ -170,6 +185,7 @@ router.post(
data: { user_id: req.params.user_id },
} as UserDeleteEvent);
+ console.log(`[Instance ban] Deleted user ${user.id} from instance in ${sw.elapsed().toString()} ms`);
res.sendStatus(204);
},
);
diff --git a/src/util/util/ElapsedTime.ts b/src/util/util/ElapsedTime.ts
index 518025c6..607b00c5 100644
--- a/src/util/util/ElapsedTime.ts
+++ b/src/util/util/ElapsedTime.ts
@@ -68,4 +68,17 @@ export class ElapsedTime {
get days(): number {
return this.totalDays;
}
+
+ toString(): string {
+ // Format: "DD.HH:MM:SS.mmmuuuNNN", with days being optional
+ const daysPart = this.days > 0 ? `${this.days}.` : "";
+ const hoursPart = this.hours.toString().padStart(2, "0");
+ const minutesPart = this.minutes.toString().padStart(2, "0");
+ const secondsPart = this.seconds.toString().padStart(2, "0");
+ const millisecondsPart = this.milliseconds.toString().padStart(3, "0");
+ const microsecondsPart = this.microseconds.toString().padStart(3, "0");
+ const nanosecondsPart = this.nanoseconds.toString().padStart(3, "0");
+
+ return `${daysPart}${hoursPart}:${minutesPart}:${secondsPart}.${millisecondsPart}${microsecondsPart}${nanosecondsPart}`;
+ }
}
\ No newline at end of file
|