Skip to content

fix: apply bulk score deltas in correct direction - #1411

Open
silentgeckoaudit3801 wants to merge 2 commits into
LabsCrypt:mainfrom
silentgeckoaudit3801:fix-bulk-score-delta-sign
Open

fix: apply bulk score deltas in correct direction#1411
silentgeckoaudit3801 wants to merge 2 commits into
LabsCrypt:mainfrom
silentgeckoaudit3801:fix-bulk-score-delta-sign

Conversation

@silentgeckoaudit3801

Copy link
Copy Markdown

Fixes #1318.

Updates �ackend/src/services/scoresService.ts so updateUserScoresBulk builds inserted/upserted score payloads with 500 + delta. That keeps positive deltas as rewards and negative deltas as penalties when the conflict update computes scores.current_score + EXCLUDED.current_score - 500.

Adds a regression in �ackend/src/services/tests/scoresService-additions.test.ts that locks the positive-delta SQL shape and rejects the old subtractive payload.

Validation: static source/API inspection only; local backend tests were not run because this environment is avoiding dependency/toolchain installation or execution.

@ogazboiz ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, the insert path really did apply positive deltas as penalties (500 - delta vs the upsert's + EXCLUDED math), and 500 + delta lines both paths up. one tiny blocker: CI lint fails on a missing trailing newline in backend/src/services/tests/scoresService-additions.test.ts (prettier at 94:6). run:

cd backend && npx prettier --write src/services/__tests__/scoresService-additions.test.ts && git commit -am "chore: prettier" && git push

and this merges.

if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

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.

[Backend] Bulk score update applies the delta with the wrong sign

2 participants