-
Notifications
You must be signed in to change notification settings - Fork 2
Add market to prod #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Market admin CRUD and basic market for users
Snowfall add to page
Revert "Snowfall add to page"
Add infinite scroll to explore page
There was a problem hiding this 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 PR introduces a market feature with a staging implementation, adds infinite scroll pagination to the explore page, and updates error messages across admin sections.
- Implements a market system with items, pricing based on user shop score, and CRUD operations for admins
- Adds a countdown timer for the market launch date
- Refactors the explore page to support infinite scroll pagination with IntersectionObserver
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/dashboard/market/MarketTimer.svelte | New countdown timer component for market launch |
| src/routes/dashboard/market/MarketItem.svelte | New component to display market items with dynamic pricing |
| src/routes/dashboard/market/+page.svelte | Market page with timer and item grid display |
| src/routes/dashboard/market/+page.server.ts | Server logic to fetch and calculate market item prices |
| src/routes/dashboard/admin/admin/market/* | Admin CRUD pages for managing market items |
| src/routes/dashboard/explore/+page.svelte | Added infinite scroll pagination |
| src/routes/dashboard/explore/+page.server.ts | Refactored to use shared devlogs fetching logic |
| src/routes/dashboard/explore/+server.ts | New API endpoint for paginated devlogs |
| src/routes/dashboard/explore/devlogs.ts | Extracted shared devlog fetching logic |
| src/lib/utils.ts | Added calculateMarketPrice function for dynamic pricing |
| src/lib/server/db/schema.ts | Added market_item and market_item_order tables |
| src/routes/dashboard/users/[id]/+page.svelte | Added market score display |
| src/routes/dashboard/users/[id]/+page.server.ts | Added shopScore to user data |
| Multiple admin files | Updated error messages from "get out, peasant" to "oi get out" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .where(and(eq(marketItem.deleted, false), eq(marketItem.id, id))); | ||
|
|
||
| if (!item) { | ||
| return error(404, { message: 'item not found' }); |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect use of return with error. The error function should be thrown, not returned. This should be 'throw error(404, ...)' instead of 'return error(404, ...)'.
| onMount(() => { | ||
| if (!hasMore || !sentinel) return; | ||
| observer = new IntersectionObserver( | ||
| (entries) => { | ||
| entries.forEach((entry) => { | ||
| if (entry.isIntersecting) { | ||
| loadMoreDevlogs(); | ||
| } | ||
| }); | ||
| }, | ||
| { rootMargin } | ||
| ); | ||
| observer.observe(sentinel); | ||
| return () => observer?.disconnect(); |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IntersectionObserver is not being disconnected when hasMore becomes false or when the sentinel element changes. The observer should be disconnected and recreated when these conditions change, or at minimum when hasMore becomes false to avoid unnecessary intersection checks.
| export function calculateMarketPrice( | ||
| minPrice: number, | ||
| maxPrice: number, | ||
| minShopScore: number, | ||
| maxShopScore: number, | ||
| userShopScore: number | ||
| ) { | ||
| if (userShopScore <= minShopScore) { | ||
| return maxPrice; | ||
| } else if (userShopScore >= maxShopScore) { | ||
| return minPrice; | ||
| } else { | ||
| const priceDiff = maxPrice - minPrice; | ||
| const shopScoreDiff = maxShopScore - minShopScore; | ||
| const m = priceDiff / shopScoreDiff; // diff_y/diff_x | ||
|
|
||
| const shopScoreRemainder = userShopScore - minShopScore; | ||
|
|
||
| // y = -mx + c | ||
| return Math.round(-m * shopScoreRemainder + maxPrice); |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calculateMarketPrice function does not handle the edge case where minShopScore equals maxShopScore, which would result in division by zero on line 73. This should be validated or handled to avoid NaN or Infinity results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that'll never happen because of >= and <=
I think this would be quite useful for now, just to set up the market items (way before the actual launch)