refactor: SSR on skills management
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { getPool } from "./database";
|
||||
import { Team, SkillCategory } from "@/lib/types";
|
||||
import { TeamMember, TeamStats, DirectionStats } from "@/lib/admin-types";
|
||||
import { SkillsService } from "./skills-service";
|
||||
|
||||
export class AdminService {
|
||||
/**
|
||||
@@ -197,18 +198,23 @@ export class AdminService {
|
||||
skillCategories: SkillCategory[];
|
||||
teamStats: TeamStats[];
|
||||
directionStats: DirectionStats[];
|
||||
skills: any[];
|
||||
}> {
|
||||
const pool = getPool();
|
||||
|
||||
try {
|
||||
// Récupérer toutes les données en parallèle
|
||||
const [teamsResult, categoriesResult, teamStats] = await Promise.all([
|
||||
pool.query(
|
||||
"SELECT id, name, direction FROM teams ORDER BY direction, name"
|
||||
),
|
||||
pool.query("SELECT id, name, icon FROM skill_categories ORDER BY name"),
|
||||
AdminService.getTeamsStats(),
|
||||
]);
|
||||
const [teamsResult, categoriesResult, teamStats, skills] =
|
||||
await Promise.all([
|
||||
pool.query(
|
||||
"SELECT id, name, direction FROM teams ORDER BY direction, name"
|
||||
),
|
||||
pool.query(
|
||||
"SELECT id, name, icon FROM skill_categories ORDER BY name"
|
||||
),
|
||||
AdminService.getTeamsStats(),
|
||||
SkillsService.getAllSkillsWithUsage(),
|
||||
]);
|
||||
|
||||
const teams = teamsResult.rows;
|
||||
const skillCategories = categoriesResult.rows.map((row) => ({
|
||||
@@ -224,6 +230,7 @@ export class AdminService {
|
||||
skillCategories,
|
||||
teamStats,
|
||||
directionStats,
|
||||
skills,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching admin data:", error);
|
||||
|
||||
Reference in New Issue
Block a user