The Day I Hit the Lucas Points Bug
Okay so last Tuesday I was messing with my loyalty program setup when bam – user points started vanishing after transactions. Checked my spreadsheet formulas first like a normal person. Everything looked fine but points kept disappearing faster than cookies at a kids party.

First Screwup: Assuming Database Was Holy
Went straight to blaming MySQL like it personally offended me. Spent 3 hours checking transaction logs before realizing the damn calculations were running twice. Facepalm moment! My “clever” async function was firing on both page load AND button click. Classic rookie mistake.
How I Fixed the Double-Dipping
Cracked open the code editor and did this:
- Slapped a disableState hook on the reward button
- Added console logs like a paranoid squirrel
- Tested with fake accounts while watching Network tabs
Took 20 minutes to fix what wasted half my day. Felt like a clown when I saw that stupid double trigger blinking in dev tools.
Second Disaster: Timezone Terror

Thought I was golden until Wednesday morning – users reported expired points reappearing! Turned out my midnight reset function was using UTC time while our servers run on PST. Points were expiring at 4pm our time like some jetlagged vampire.
The Midnight Fix Dance
Went full detective mode:
- Replaced all new Date() calls with dayjs
- Hardcoded our timezone in the expiration cron job
- Ran manual tests changing my system clock like a time traveler
Now points die precisely at midnight local time. Added bonus: finally learned to stop treating dates like they’re simple strings.
Final Boss: The Phantom Decimal
Thursday brought weird math – user with 137 points redeemed 100 but got 36.99 leftover? My “simple” math was doing floating point gymnastics behind the scenes. 137 – 100 became 36.999999 you kidding me?
Nuclear solution:

- Ditched all float calculations
- Multiplied points by 100 to work in integers
- Only divided by 100 for display
Feels overkill for loyalty points but now numbers add up like God intended. The lesson? Computers suck at math unless you hold their hand.
Epilogue
The Lucas Points system now runs smoother than my grandpa’s old Cadillac. Took three facepalm moments and some ugly debugging but hey – that’s coding life! Moral of the story: never trust your first assumption. Especially when the damn points keep disappearing.