fix: apply bulk score deltas in correct direction - #1411
Open
silentgeckoaudit3801 wants to merge 2 commits into
Open
fix: apply bulk score deltas in correct direction#1411silentgeckoaudit3801 wants to merge 2 commits into
silentgeckoaudit3801 wants to merge 2 commits into
Conversation
ogazboiz
requested changes
Aug 3, 2026
ogazboiz
left a comment
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.