Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit b2a8426

Browse files
committed
refactor(search): streamline user search logic to utilize public profiles
1 parent 3d9e81c commit b2a8426

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

dist/controllers/SearchController.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@ let SearchController = class SearchController {
5757
const detailledUsers = await Promise.all(users.map(async (user) => {
5858
if (user.disabled)
5959
return null;
60-
const { inventory } = await this.inventoryService.getInventory(user.user_id);
61-
const formattedInventory = await (0, helpers_1.formatInventory)(inventory, this.itemService);
62-
const items = await this.itemService.getAllItems();
63-
const ownedItems = items.filter((i) => !i.deleted && i.owner === user?.user_id).map(helpers_1.mapItem);
64-
const games = await this.gameService.listGames();
65-
const createdGames = games.filter(g => g.owner_id === user?.user_id).map(g => (0, helpers_1.filterGame)(g, user?.user_id));
66-
return { ...(0, helpers_1.mapUserSearch)(user), inventory: formattedInventory, ownedItems, createdGames };
60+
// Utilisation du profil public complet
61+
const publicProfile = await this.userService.getUserWithPublicProfile(user.user_id);
62+
return { id: user.user_id, ...publicProfile };
6763
}));
6864
const items = await this.itemService.searchItemsByName(query);
6965
const games = await this.gameService.listGames();

src/controllers/SearchController.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,9 @@ export class SearchController {
6565
const users: User[] = await this.userService.searchUsersByUsername(query);
6666
const detailledUsers = await Promise.all(users.map(async (user) => {
6767
if (user.disabled) return null;
68-
const { inventory } = await this.inventoryService.getInventory(user.user_id);
69-
const formattedInventory = await formatInventory(inventory, this.itemService);
70-
const items = await this.itemService.getAllItems();
71-
const ownedItems = items.filter((i) => !i.deleted && i.owner === user?.user_id).map(mapItem);
72-
const games = await this.gameService.listGames();
73-
const createdGames = games.filter(g => g.owner_id === user?.user_id).map(g => filterGame(g, user?.user_id));
74-
return { ...mapUserSearch(user), inventory: formattedInventory, ownedItems, createdGames };
68+
// Utilisation du profil public complet
69+
const publicProfile = await this.userService.getUserWithPublicProfile(user.user_id);
70+
return { id: user.user_id, ...publicProfile };
7571
}));
7672

7773
const items = await this.itemService.searchItemsByName(query);

0 commit comments

Comments
 (0)