Skip to content

Conversation

@bbarni2020
Copy link
Collaborator

I think this would be quite useful for now, just to set up the market items (way before the actual launch)

Copilot AI review requested due to automatic review settings December 24, 2025 14:20
Copy link
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 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' });
Copy link

Copilot AI Dec 24, 2025

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, ...)'.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +71
onMount(() => {
if (!hasMore || !sentinel) return;
observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
loadMoreDevlogs();
}
});
},
{ rootMargin }
);
observer.observe(sentinel);
return () => observer?.disconnect();
Copy link

Copilot AI Dec 24, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +78
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);
Copy link

Copilot AI Dec 24, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

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 <=

@ArcaEge ArcaEge changed the title Staging Add market to prod Dec 24, 2025
@ArcaEge ArcaEge merged commit 22bf65d into main Dec 24, 2025
1 check passed
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.

3 participants