Skip to content

Refactor duplicated attestation repository implementations into one typed repository on the shared base #647

Description

@Baskarayelu

📋 Description

There are two parallel attestation repository files: src/repositories/attestationRepository.ts and src/repositories/attestations.repository.ts, while the project standardizes data access on a shared typed base in src/db/repository.ts (BaseRepository) re-exported via src/repositories/index.ts. Two implementations of the same concept drift apart and double the surface for bugs.

This issue consolidates them into a single repository extending BaseRepository, updates all callers, and removes the redundant file.

Why this matters: duplicate repositories are a maintenance trap — a fix applied to one silently misses the other. One typed repository on the shared base is the canonical pattern the rest of the codebase already follows.

🎯 Requirements & Context

Functional requirements

  • Pick the canonical attestation repository (extending BaseRepository) and migrate any unique methods from the other into it.
  • Update every import site to the consolidated repository (search the whole src tree).
  • Delete the redundant file and remove its export from src/repositories/index.ts.
  • Preserve all existing query behavior and signatures used by callers (e.g. attestations route/service).
  • Ensure existing attestation tests still pass; add a test for any method that lacked coverage after the merge.

Context & constraints

  • This is a behavior-preserving refactor; do not change query semantics.
  • If the two files actually have divergent behavior, document the difference in the PR and choose the correct one explicitly.

🛠️ Suggested Execution

1. Fork & branch

git checkout -b refactor/consolidate-attestation-repository

2. Implement changes

  • Diff the two files; merge into the BaseRepository-derived one; rewire imports; delete the other.
  • Add TSDoc on the consolidated repository methods.

3. Test & commit

npm run test -- attestation
npm run lint
npm run build
  • Edge cases: callers importing the deleted path, divergent method names, pagination/filter parity.

Example commit message

refactor(db): consolidate duplicate attestation repositories onto BaseRepository

Merges attestations.repository.ts into the canonical attestationRepository
and removes the redundant file.

✅ Acceptance Criteria & Guidelines

Requirement Target
Single repository on BaseRepository, redundant file removed Required
All callers updated, behavior preserved Required
Coverage of merged methods ≥ 95% where testable
npm run lint + npm run build clean Required
Timeframe 96 hours from assignment

💬 Community & Support

Questions and design discussion — join the GrantFox contributor community on Discord: https://discord.gg/nmnPBkBge

Please comment on this issue to ask to be assigned before you start. 🚀

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions