feat(browse): icône crayon inline sur les tuiles + apiCount récursif
- Bouton modifier réduit à l'icône crayon, placé à côté du titre de la tuile - apiCount dans CategoryWithCounts inclut désormais les APIs de tous les sous-dossiers récursivement (countApisRecursively) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -81,6 +81,13 @@ export class CategoriesService {
|
||||
await this.categoryRepo.delete(id);
|
||||
}
|
||||
|
||||
private async countApisRecursively(categoryId: string): Promise<number> {
|
||||
const direct = await this.apiRepo.count({ where: { categoryId } });
|
||||
const children = await this.categoryRepo.find({ where: { parentId: categoryId }, select: ['id'] });
|
||||
const childCounts = await Promise.all(children.map((c) => this.countApisRecursively(c.id)));
|
||||
return direct + childCounts.reduce((sum, n) => sum + n, 0);
|
||||
}
|
||||
|
||||
async browse(categoryId: string | null): Promise<CategoryBrowseResponse> {
|
||||
/* 1. Charge la catégorie courante */
|
||||
let currentCategory: CategoryEntity | null = null;
|
||||
@@ -111,7 +118,7 @@ export class CategoriesService {
|
||||
const subcategories: CategoryWithCounts[] = await Promise.all(
|
||||
directChildren.map(async (child) => {
|
||||
const subcategoryCount = await this.categoryRepo.count({ where: { parentId: child.id } });
|
||||
const apiCount = await this.apiRepo.count({ where: { categoryId: child.id } });
|
||||
const apiCount = await this.countApisRecursively(child.id);
|
||||
return { ...toCategory(child), subcategoryCount, apiCount };
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user