Skip to content

Chore/bun#204

Merged
Angus-Paillaugue merged 5 commits into
mainfrom
chore/bun
Jan 31, 2026
Merged

Chore/bun#204
Angus-Paillaugue merged 5 commits into
mainfrom
chore/bun

Conversation

@Angus-Paillaugue
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings January 31, 2026 17:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request migrates the database layer from node-postgres (pg) to Bun's native SQL implementation, removes several language translations (Spanish, Japanese, German), and adds a new feature for planning outfits for future dates ("provisional outfits").

Changes:

  • Migrated all database access objects (DAOs) from pg connection pool to Bun's sql tagged template literals
  • Added provisional outfit planning functionality allowing users to create outfits for future dates
  • Removed Spanish, Japanese, and German language support, keeping only English and French

Reviewed changes

Copilot reviewed 37 out of 39 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
vite.config.ts Added external configuration for 'bun' package
src/routes/app/Swiper.svelte Added provisional date support with calendar picker
src/routes/app/MixAndMatch.svelte Added createdAt date to outfit creation
src/routes/app/+page.svelte Implemented UI for viewing and managing provisional outfits
src/routes/api/wardrobe/outfit/save/+server.ts Updated schema to accept createdAt field
src/routes/api/wardrobe/outfit/generate/+server.ts Removed debug logging, improved error logging
src/routes/api/social/comment/+server.ts Removed unused import
src/lib/utils/date.ts Added isInFuture method and improved formatDate with relative dates
src/lib/types.ts Reordered OutfitPreviewZ omit parameters
src/lib/server/db/*.ts Migrated all database queries from pg to Bun SQL
src/lib/i18n/messages/*.json Removed de/sp/jp translations, added date translations to en/fr
src/lib/components/wardrobe/OutfitCard.svelte Added capitalize class to date display
sql/migrations/* Added migration for cascade delete, updated init script
scripts/db/*.ts Migrated database scripts to Bun SQL
package.json Removed pg and @types/pg dependencies
docker-compose*.yaml Removed init.sql volume mount
entrypoint.sh Added DATABASE_URL export construction
Comments suppressed due to low confidence (2)

src/lib/server/db/outfit.ts:74

  • N+1 query problem: For each outfit, this code makes separate database queries to fetch clothing items (line 60-62 for outfit_clothing_items, then line 67 for each item). This results in 1 + N + M queries where N is the number of outfits and M is the total number of clothing items across all outfits. Consider using a JOIN or batching queries to fetch all outfit items and clothing items in fewer queries for better performance.
    for (const row of rows) {
      const itemsRows = await sql<
        OutfitItemTable[]
      >`SELECT * FROM outfit_clothing_items WHERE outfit_id = ${row.id}`;
      const clothingItemIds = itemsRows.map((r) => r.clothing_item_id);

      const clothingItems: ClothingItem[] = [];
      for (const clothingItemId of clothingItemIds) {
        const item = await ClothingItemDAO.getClothingItemById(clothingItemId);
        if (item) {
          clothingItems.push(item);
        }
      }

      outfits.push(OutfitDAO.convertToOutfit(row, clothingItems));
    }

src/lib/server/db/social.ts:16

  • N+1 query problem: This function makes 1 query to get follower IDs, then N additional queries to getUserById for each user (line 12). This results in 1 + N database queries. Consider using a JOIN to fetch all user data in a single query, or batch the getUserById calls if they involve complex logic that must be reused.
  static async getFollowingUsers(userId: User['id']): Promise<User[]> {
    const result = await sql`SELECT u.id FROM followers f
       JOIN users u ON f.following_id = u.id
       WHERE f.follower_id = ${userId}`;
    const users: User[] = [];
    for (const userId of result.rows) {
      const user = await UserDAO.getUserById(userId);
      delete user.passwordHash;
      users.push(user);
    }
    return users;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/server/db/outfit.ts
Comment thread src/lib/server/db/social.ts Outdated
Comment thread src/routes/app/Swiper.svelte
Comment thread src/lib/server/db/outfit.ts Outdated
Comment thread src/lib/server/db/user.ts
Comment thread src/lib/server/db/outfit.ts Outdated
Comment thread src/lib/server/db/clothingItem.ts Outdated
Comment thread src/lib/server/db/user.ts
Comment thread vite.config.ts
Comment thread src/lib/server/db/user.ts
@Angus-Paillaugue Angus-Paillaugue merged commit 3c43c8c into main Jan 31, 2026
2 checks passed
@Angus-Paillaugue Angus-Paillaugue deleted the chore/bun branch January 31, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants