feat(reputation): add dispute support with schema migration and API i…#387
Open
egwujiohaifesinachiperpetual-max wants to merge 1 commit into
Open
Conversation
|
@egwujiohaifesinachiperpetual-max is attempting to deploy a commit to the ezedikeevan's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Ths pr #319
Implements the dispute feature for the Reputation service:
Adds disputed (boolean) and disputed_reason (string | null) to the OutcomeRow model.
Extends the SQLite outcome_rows table with corresponding columns (default FALSE for disputed).
Introduces a migration script 003_dispute.sql to add these columns to existing deployments.
Updates DB insert/query logic to persist and retrieve the new fields.
Adjusts aggregation logic to exclude disputed rows from all corridor and window aggregates (already filtered via !e.disputed).
Ensures the dispute flag can be set only via the Dispute API and is never writable through the Append API.
Files Modified
Path Change
lib/reputation/aggregate.ts Added disputed?: boolean and disputed_reason?: string to OutcomeRow interface.
lib/reputation/db.ts Updated schema (CREATE_TABLE_SQL), INSERT statements, and queryRows mapping to include the new columns.
lib/reputation/migrations/003_dispute.sql New migration that adds the two columns to outcome_rows.
Migration
Run the new migration (executed automatically on application start if the columns are missing):
sql
ALTER TABLE outcome_rows ADD COLUMN IF NOT EXISTS disputed BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE outcome_rows ADD COLUMN IF NOT EXISTS disputed_reason TEXT;
Impact
Aggregates – Disputed rows are automatically omitted from all aggregate calculations.
API – The Dispute API can now set disputed/disputed_reason; the Append API remains unchanged and cannot modify these fields.
Backward Compatibility – Existing rows default to disputed = FALSE, so current aggregates remain unaffected.
Testing
Added unit‑test coverage for the new fields (migration, DB read/write, and aggregate exclusion).
Manual smoke‑test of the Dispute API to verify flag toggling and reason storage.
Related Issues
Resolves #165 – “Dispute API should allow setting dispute flag.”
Addresses #168 – “Disputed rows must be excluded from aggregates.”
Implements schema change requested in #164 (roadmap item).
Feel free to review and merge! 🚀