Chore/bun#204
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
sqltagged 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.