Skip to content

feat: Grant Data Quality Score (#166) - #183

Merged
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
ifygreg01-best:feat/grant-data-quality-score-166
Sep 1, 2026
Merged

feat: Grant Data Quality Score (#166)#183
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
ifygreg01-best:feat/grant-data-quality-score-166

Conversation

@ifygreg01-best

Copy link
Copy Markdown

Summary

Implements issue #166 — a system that evaluates whether grant records contain the essential information needed by users.

Changes

frontend/src/types/grant.ts

  • Extended GrantRecord with 8 optional enrichment fields (description, website, contactEmail, category, amount, currency, recipientName, recipientAddress, updatedAt)
  • Added QualityGrade (A/B/C/D/F), QualityField, and GrantQualityScore types
  • Added ExportRequester / ExportRole types (already imported by grant-export.ts)

frontend/src/lib/grant-quality.ts (new)

  • QUALITY_FIELD_WEIGHTS — 11 fields with weights summing to exactly 100
  • scoreGrantQuality(grant) — returns 0–100 score, letter grade, present/missing field lists
  • scoreToGrade(score) — A (≥90), B (≥75), C (≥60), D (≥40), F (<40)
  • scoreAllGrants(grants) — scores and sorts worst-first
  • listLowQualityGrants(grants, threshold=75) — admin filter helper
  • formatQualitySummary() / formatQualityLabel() — display utilities

frontend/src/lib/grant-quality.test.ts (new)

  • 62 tests: weight table integrity, grade thresholds, field presence edge cases, full/minimal/partial/empty scoring, admin utilities, sort order, threshold filtering

frontend/src/components/AdminGrantQualityPanel.tsx (new)

  • Summary stats (total, complete, needs attention, average score)
  • Sortable list (worst-first / best-first / alphabetical)
  • Filter toggle for low-quality records only
  • Per-row expandable missing-field detail
  • Colour-coded grade badges + score progress bars
  • Fully accessible (aria-expanded, aria-live, role=progressbar, aria-label)

Acceptance Criteria

  • ✅ Required information fields are defined (11 weighted fields in QUALITY_FIELD_WEIGHTS)
  • ✅ Incomplete grants receive a lower quality score (proportional to missing fields)
  • ✅ Administrators can identify records that need improvement (listLowQualityGrants() + AdminGrantQualityPanel)

Tests

All 62 new tests pass. All pre-existing tests unaffected (grant-export: 18/18, grant-import: 22/22).

- Extend GrantRecord with optional enrichment fields (description,
  website, contactEmail, category, amount, currency, recipientName,
  recipientAddress, updatedAt) and add QualityGrade / QualityField /
  GrantQualityScore types plus ExportRequester/ExportRole

- Add grant-quality.ts with weighted scoring engine (weights sum to
  100), scoreGrantQuality(), scoreAllGrants(), listLowQualityGrants(),
  scoreToGrade(), formatQualitySummary(), formatQualityLabel()

- Add 62-test suite in grant-quality.test.ts covering weight integrity,
  grade thresholds, field presence edge cases, full/partial/empty
  scoring, admin helpers, and display formatters

- Add AdminGrantQualityPanel React component with summary stats,
  sortable/filterable list, per-row missing-field detail, colour-coded
  grade badges, and full ARIA accessibility

Closes Core-Foundry#166
@Abd-Standard
Abd-Standard merged commit 5df9ca4 into Core-Foundry:main Sep 1, 2026
2 of 3 checks passed
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.

2 participants