Skip to content

feat: add computePriceChange helper for key price percentage change - #435

Closed
Ghadaffijr wants to merge 1 commit into
accesslayerorg:mainfrom
Ghadaffijr:feat/compute-price-change
Closed

feat: add computePriceChange helper for key price percentage change#435
Ghadaffijr wants to merge 1 commit into
accesslayerorg:mainfrom
Ghadaffijr:feat/compute-price-change

Conversation

@Ghadaffijr

Copy link
Copy Markdown
Contributor
  • Add computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts
  • Returns { percent: number, direction: 'up' | 'down' | 'flat' }
  • Returns flat when previous is zero or current equals previous
  • 7 unit tests covering: price up, price down, no change, zero previous, both zero

Closes #429

Summary

i. Adds computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts as a shared helper for computing key price movement across the creator list and creator detail pages

ii. Returns { percent: number, direction: 'up' | 'down' | 'flat' } so formatting and sign logic are consistent wherever price change is displayed

iii. Returns flat with percent: 0 in both edge cases: when previous is zero (undefined division) and when current equals previous (no movement)

iv. Converts bigint inputs to number at the division boundary only, preserving precision for the comparison logic

Closes #429

Testing

-[x] pnpm lint
-[x] pnpm build
-[x] 7 unit tests added covering: price increase, price decrease, large increase, large decrease, equal values, zero previous, both zero

Checklist

-[x] Linked issue or backlog item
-[x] Scope is limited to the stated change
-[x] Updated docs if behavior or setup changed
-[ ] Added screenshots for UI changes when relevant — N/A, pure utility function with no UI

- Add computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts
- Returns { percent: number, direction: 'up' | 'down' | 'flat' }
- Returns flat when previous is zero or current equals previous
- 7 unit tests covering: price up, price down, no change, zero previous, both zero

Closes accesslayerorg#429
@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for accesslayer ready!

Name Link
🔨 Latest commit 56f7157
🔍 Latest deploy log https://app.netlify.com/projects/accesslayer/deploys/6a3cef91eb381600084c2fd2
😎 Deploy Preview https://deploy-preview-435--accesslayer.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.

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@Ghadaffijr Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@github-actions

Copy link
Copy Markdown

👋 Hey @Ghadaffijr, thanks for your contribution!

This PR is targeting main directly. We use main for stable releases only — all contributions should be opened against the dev branch instead.

Please close this PR and reopen it with dev as the base branch. If you're unsure how to do that, you can change the base branch using the Edit button at the top of this PR page.

Closing this PR automatically. See you in dev! 🚀

@github-actions github-actions Bot closed this Jun 25, 2026
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.

Add helper for computing percentage price change between two key price values

1 participant