Skip to content

Conversation

@EricWeng23
Copy link
Contributor

This PR refactors the analytics page implemented in #38, using cache data from the new fundraiser analytics backend route /fundraiser/:id/analytics. Previously we had designated frontend route for analytics and order data in seller/fundraiser/[id]/analytics and seller/fundraiser/[id]/orders respectively. For the sake of simplicity, we are merging these two pages into a single route seller/fundraiser/[id].

Screen.Recording.2025-10-26.at.4.09.01.PM.mov

NOTE:
Notice that when updating the pickup status of an order, this does not directly update the database and only updates the local SWR cache. To reflect the changes, we must refresh the page for the change to propagate to the database and for the updated cache data to render in the frontend. This was a persistent bug since SP24, and we will have to address this sooner or later!

@netlify
Copy link

netlify bot commented Oct 26, 2025

Deploy Preview for curaise ready!

Name Link
🔨 Latest commit d3e6802
🔍 Latest deploy log https://app.netlify.com/projects/curaise/deploys/68fe82afd15a7300080ebae1
😎 Deploy Preview https://deploy-preview-64--curaise.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Arsh-S
Copy link
Contributor

Arsh-S commented Oct 27, 2025

Hey Eric, great work on the cached analytics system! I believe there is an edge case/bug that can cause double-counting of revenue and incorrect pending order counts:

When an order's payment is CONFIRMED (but not yet picked up):

  1. Cache recalculation treats it as paid:
  • Adds revenue to the cache calculateAndCacheFundraiserAnalytics
  • Does NOT add to pending_orders (only non-paid orders increment pending)
  1. Later, when the order is picked up, updateCacheForOrderPickup:
  • Adds revenue AGAIN → double-count
  • Decrements pending (even though this order was never in pending!) → can go negative

Root Cause:

  • In completeOrderPickup, the query doesn't SELECT paymentStatus, so updateCacheForOrderPickup assumes every picked-up order was previously pending and always adds revenue.

Suggested Fix

  1. Add paymentStatus to the query in completeOrderPickup
  2. Update the function to pass paymentStatus
  3. Check if the order was already CONFIRMED before updating analytics, and update the proper analytics only.

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