2026-07-30 11:50:48 +07:00
|
|
|
import { createChildLogger } from "@/shared/logger/index";
|
2026-06-13 11:24:42 +07:00
|
|
|
import { dashboardRepository } from "./dashboard.repository.js";
|
|
|
|
|
|
|
|
|
|
const logger = createChildLogger("dashboard.service");
|
|
|
|
|
|
|
|
|
|
export interface ListUsersQuery {
|
|
|
|
|
limit: number;
|
|
|
|
|
cursor?: string;
|
|
|
|
|
search?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class DashboardService {
|
|
|
|
|
async getStats() {
|
|
|
|
|
logger.debug("Fetching dashboard stats");
|
|
|
|
|
return dashboardRepository.getStats();
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-01 23:06:00 +07:00
|
|
|
async getActivity(days: number) {
|
|
|
|
|
logger.debug({ days }, "Fetching dashboard activity");
|
|
|
|
|
return dashboardRepository.getActivity(days);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-13 11:24:42 +07:00
|
|
|
async listUsers(query: ListUsersQuery) {
|
|
|
|
|
logger.debug({ query }, "Listing dashboard users");
|
|
|
|
|
return dashboardRepository.listUsers(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getUserDetail(userId: string) {
|
|
|
|
|
logger.debug({ userId }, "Fetching user detail");
|
|
|
|
|
return dashboardRepository.getUserDetail(userId);
|
|
|
|
|
}
|
2026-06-13 12:24:32 +07:00
|
|
|
|
2026-06-13 13:51:21 +07:00
|
|
|
async listChannels(query: {
|
|
|
|
|
limit: number;
|
|
|
|
|
search?: string;
|
|
|
|
|
guildId?: string;
|
|
|
|
|
}) {
|
2026-06-13 12:24:32 +07:00
|
|
|
logger.debug({ query }, "Listing dashboard channels");
|
|
|
|
|
return dashboardRepository.listChannels(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getChannelDetail(channelId: string) {
|
|
|
|
|
logger.debug({ channelId }, "Fetching channel detail");
|
|
|
|
|
return dashboardRepository.getChannelDetail(channelId);
|
|
|
|
|
}
|
2026-08-05 10:20:12 +07:00
|
|
|
|
|
|
|
|
async getTopReactions(limit: number) {
|
|
|
|
|
logger.debug({ limit }, "Fetching top reactions");
|
|
|
|
|
return dashboardRepository.getTopReactions(limit);
|
|
|
|
|
}
|
2026-08-05 11:29:56 +07:00
|
|
|
|
|
|
|
|
async getTopReactors(limit: number) {
|
|
|
|
|
logger.debug({ limit }, "Fetching top reactors");
|
|
|
|
|
return dashboardRepository.getTopReactors(limit);
|
|
|
|
|
}
|
2026-06-13 11:24:42 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const dashboardService = new DashboardService();
|