From 58f5d4f7cef5c8991127912fb746596b5c7d5ae9 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Wed, 3 Jun 2026 18:20:27 +0700 Subject: [PATCH] style(analytics): reorder imports and apply consistent formatting --- .../modules/analytics/analytics.controller.ts | 13 +++++++------ .../modules/analytics/analytics.repository.ts | 19 +++++++++++-------- .../src/modules/analytics/analytics.routes.ts | 2 +- .../modules/analytics/analytics.service.ts | 7 +++++-- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/services/backend/src/modules/analytics/analytics.controller.ts b/services/backend/src/modules/analytics/analytics.controller.ts index 34890dd..99017d9 100644 --- a/services/backend/src/modules/analytics/analytics.controller.ts +++ b/services/backend/src/modules/analytics/analytics.controller.ts @@ -1,9 +1,6 @@ -import type { NextFunction, Request, Response } from "express"; import { createChildLogger } from "@bete/shared/logger"; -import { - asyncHandler, - requireParam, -} from "../../shared/middlewares/index.js"; +import type { NextFunction, Request, Response } from "express"; +import { asyncHandler, requireParam } from "../../shared/middlewares/index.js"; import { analyticsQuerySchema } from "./analytics.schema.js"; import { analyticsService } from "./analytics.service.js"; @@ -28,7 +25,11 @@ export function handleGetDailyTrend( next: NextFunction, ) { return asyncHandler(async (req: Request, res: Response) => { - const guildId = requireParam(req.query.guildId, "query parameter", "guildId"); + const guildId = requireParam( + req.query.guildId, + "query parameter", + "guildId", + ); const hours = req.query.hours ? Number(req.query.hours) : 24; logger.debug({ guildId, hours }, "Handling get daily trend"); const result = await analyticsService.getDailyTrend(guildId, hours); diff --git a/services/backend/src/modules/analytics/analytics.repository.ts b/services/backend/src/modules/analytics/analytics.repository.ts index 31f0e02..cb6f17b 100644 --- a/services/backend/src/modules/analytics/analytics.repository.ts +++ b/services/backend/src/modules/analytics/analytics.repository.ts @@ -1,5 +1,5 @@ -import { getPool } from "../../shared/database/index.js"; import { createChildLogger } from "@bete/shared/logger"; +import { getPool } from "../../shared/database/index.js"; const logger = createChildLogger("analytics.repository"); @@ -153,10 +153,7 @@ export class AnalyticsRepository { hours = 24, limit = 10, ) { - logger.debug( - { guildId, channelId, hours, limit }, - "Getting top violators", - ); + logger.debug({ guildId, channelId, hours, limit }, "Getting top violators"); const pool = getPool(); const filter = buildTimeFilter(guildId, channelId, hours); @@ -193,7 +190,10 @@ export class AnalyticsRepository { warned_count: Number(r.warned_count ?? 0), violation_score: Number(r.violation_score ?? 0), worst_flags: (r.worst_flags as string | null) - ? (r.worst_flags as string).split(",").map((s) => s.trim()).filter(Boolean) + ? (r.worst_flags as string) + .split(",") + .map((s) => s.trim()) + .filter(Boolean) : [], last_violation: Number(r.last_violation ?? 0), })); @@ -346,7 +346,10 @@ export class AnalyticsRepository { hours = 24, limit = 20, ) { - logger.debug({ guildId, channelId, hours, limit }, "Getting moderation actions"); + logger.debug( + { guildId, channelId, hours, limit }, + "Getting moderation actions", + ); const pool = getPool(); const filter = buildTimeFilter(guildId, channelId, hours); @@ -368,7 +371,7 @@ export class AnalyticsRepository { m.content FROM moderation_actions ma LEFT JOIN messages m ON m.id = ma.message_id - ${filter.where.replace('guild_id', 'ma.guild_id').replace('created_at', 'ma.created_at')} + ${filter.where.replace("guild_id", "ma.guild_id").replace("created_at", "ma.created_at")} ORDER BY ma.created_at DESC LIMIT $${filter.params.length + 1} `, diff --git a/services/backend/src/modules/analytics/analytics.routes.ts b/services/backend/src/modules/analytics/analytics.routes.ts index 0a1f46e..ce36e54 100644 --- a/services/backend/src/modules/analytics/analytics.routes.ts +++ b/services/backend/src/modules/analytics/analytics.routes.ts @@ -9,8 +9,8 @@ import { handleGetModerationActions, handleGetModerationStats, handleGetOverview, - handleGetTopViolators, handleGetTopics, + handleGetTopViolators, handleGetUserLeaderboard, } from "./analytics.controller.js"; diff --git a/services/backend/src/modules/analytics/analytics.service.ts b/services/backend/src/modules/analytics/analytics.service.ts index a4fa252..4ade019 100644 --- a/services/backend/src/modules/analytics/analytics.service.ts +++ b/services/backend/src/modules/analytics/analytics.service.ts @@ -1,6 +1,6 @@ -import { config } from "../../shared/config/index.js"; import { ForbiddenError, ValidationError } from "@bete/shared/errors"; import { createChildLogger } from "@bete/shared/logger"; +import { config } from "../../shared/config/index.js"; import { analyticsRepository } from "./analytics.repository.js"; import type { AnalyticsQuery } from "./analytics.schema.js"; @@ -99,7 +99,10 @@ export class AnalyticsService { limit = 20, ) { this.assertMonitorGuild(guildId); - logger.debug({ guildId, channelId, hours, limit }, "Getting moderation actions"); + logger.debug( + { guildId, channelId, hours, limit }, + "Getting moderation actions", + ); return analyticsRepository.getModerationActions( guildId, channelId,