feat: importance in db and mentorcard home colors
This commit is contained in:
@@ -20,6 +20,7 @@ export class SkillsService {
|
||||
'name', s.name,
|
||||
'description', s.description,
|
||||
'icon', s.icon,
|
||||
'importance', s.importance,
|
||||
'links', COALESCE(
|
||||
(SELECT json_agg(sl.url ORDER BY sl.id)
|
||||
FROM skill_links sl
|
||||
@@ -249,6 +250,7 @@ export class SkillsService {
|
||||
categoryId: string;
|
||||
category: string;
|
||||
usageCount: number;
|
||||
importance: string;
|
||||
}>
|
||||
> {
|
||||
const pool = getPool();
|
||||
@@ -260,11 +262,12 @@ export class SkillsService {
|
||||
s.icon,
|
||||
sc.id as category_id,
|
||||
sc.name as category_name,
|
||||
s.importance,
|
||||
COUNT(DISTINCT se.id) as usage_count
|
||||
FROM skills s
|
||||
LEFT JOIN skill_categories sc ON s.category_id = sc.id
|
||||
LEFT JOIN skill_evaluations se ON s.id = se.skill_id AND se.is_selected = true
|
||||
GROUP BY s.id, s.name, s.description, s.icon, sc.id, sc.name
|
||||
GROUP BY s.id, s.name, s.description, s.icon, sc.id, sc.name, s.importance
|
||||
ORDER BY s.name
|
||||
`;
|
||||
|
||||
@@ -279,6 +282,7 @@ export class SkillsService {
|
||||
categoryId: row.category_id,
|
||||
category: row.category_name,
|
||||
usageCount: parseInt(row.usage_count) || 0,
|
||||
importance: row.importance || "standard",
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Error fetching skills with usage:", error);
|
||||
@@ -286,6 +290,32 @@ export class SkillsService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update skill importance
|
||||
*/
|
||||
static async updateSkillImportance(
|
||||
skillId: string,
|
||||
importance: "incontournable" | "majeure" | "standard"
|
||||
): Promise<void> {
|
||||
const pool = getPool();
|
||||
const query = `
|
||||
UPDATE skills
|
||||
SET importance = $1, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $2
|
||||
`;
|
||||
|
||||
try {
|
||||
const result = await pool.query(query, [importance, skillId]);
|
||||
|
||||
if (result.rowCount === 0) {
|
||||
throw new Error("Skill not found");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error updating skill importance:", error);
|
||||
throw new Error("Failed to update skill importance");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new skill for admin
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user