Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 7 additions & 34 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
# Outlier Detection Filter Implementation
# TODO: Add Indexes for Historical Data Query Performance

## Approved Plan Steps
## Plan
- [x] Analyze schema.prisma and query patterns in history.ts / intelligenceService.ts
- [x] Edit prisma/schema.prisma: Add `@@index([updatedAt])` to PriceHistory model
- [x] Edit prisma/schema.prisma: Add `@@index([symbol])` to Currency model
- [x] Run Prisma generate and db push to apply indexes (Node/npm not available in current terminal; user must run locally)
- [ ] Verify changes and test endpoints

### 1. [x] Create src/logic/outlierFilter.ts

- Implement filterOutliers() with IQR method
- Add isOutlier() helper

### 2. [x] Update src/services/marketRate/types.ts

- Re-export filterOutliers

### 3. [x] Update ghsFetcher.ts

- Import filterOutliers
- Filter rateValues before calculateMedian

### 4. [x] Update kesFetcher.ts

- Import filterOutliers
- Filter in fetchFromBinance() and other price collection points

### 5. [x] Update ngnFetcher.ts

- Import filterOutliers
- Filter rateValues before calculateMedian

### 6. [x] Test changes

- Run npm test
- Manual test: import MarketRateService and call getRate('GHS')

### 7. [x] Complete

- attempt_completion
3 changes: 3 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ model PriceHistory {

@@index([currency, timestamp])
@@index([timestamp])
@@index([updatedAt])
@@unique([currency, source, timestamp])
}

Expand All @@ -35,6 +36,8 @@ model Currency {
updatedAt DateTime @updatedAt

priceHistory PriceHistory[]

@@index([symbol])
}

// On-Chain Confirmed Price Model
Expand Down
Loading