2026-06-02 21:06:42 +07:00
|
|
|
import { createChildLogger } from "@bete/shared/logger";
|
2026-06-09 10:16:04 +07:00
|
|
|
import { config } from "../../shared/config/index.js";
|
|
|
|
|
import type { AnalysisSearchQuery } from "./analysis.repository.js";
|
|
|
|
|
import { analysisRepository } from "./analysis.repository.js";
|
2026-06-02 00:11:29 +07:00
|
|
|
|
|
|
|
|
const logger = createChildLogger("analysis.service");
|
|
|
|
|
|
2026-06-09 10:16:04 +07:00
|
|
|
export type { AnalysisSearchQuery };
|
2026-06-02 12:17:51 +07:00
|
|
|
|
2026-06-02 00:11:29 +07:00
|
|
|
export class AnalysisService {
|
|
|
|
|
async search(query: AnalysisSearchQuery) {
|
|
|
|
|
const { q = "", channelId, limit = 20 } = query;
|
|
|
|
|
const guildId = config.MONITOR_GUILD_ID;
|
|
|
|
|
|
|
|
|
|
logger.debug({ q, channelId, limit, guildId }, "Searching analysis");
|
|
|
|
|
|
2026-06-09 10:16:04 +07:00
|
|
|
const rows = await analysisRepository.search({
|
|
|
|
|
q,
|
|
|
|
|
channelId,
|
|
|
|
|
guildId,
|
|
|
|
|
limit,
|
|
|
|
|
});
|
2026-06-02 00:11:29 +07:00
|
|
|
|
|
|
|
|
return { results: rows };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const analysisService = new AnalysisService();
|