Skip to content

Export resolveDbPath and make DailyRefinementJob DB path injectable with tests#586

Draft
Copilot wants to merge 2 commits intofix-daily-refinement-db-path-12076064593165869744from
copilot/sub-pr-574-ffd45922-052e-4a83-997d-9a3c933a8f9a
Draft

Export resolveDbPath and make DailyRefinementJob DB path injectable with tests#586
Copilot wants to merge 2 commits intofix-daily-refinement-db-path-12076064593165869744from
copilot/sub-pr-574-ffd45922-052e-4a83-997d-9a3c933a8f9a

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Description

The DailyRefinementJob DB path was derived from a non-exported module-level constant, making it impossible to assert the default value in tests. This refactors the path derivation into an exported, injectable function and adds focused tests to enforce the data/issues.db default.

scheduler/dailyRefinementJob.ts

  • Replace module-level const dbPath with exported resolveDbPath(env?) — accepts an env object so tests can pass controlled environments without touching process.env
  • DailyRefinementJob constructor now accepts optional dbPath param (default: resolveDbPath())

tests/dailyRefinement.test.ts

  • Add describe("resolveDbPath") with two tests: default path ends with data/issues.db when env is empty; custom path is returned when DB_PATH is set
// Before
const dbPath = process.env.DB_PATH || path.join(__dirname, "../data/issues.db");

// After
export function resolveDbPath(env: NodeJS.ProcessEnv = process.env): string {
  return env.DB_PATH || path.join(__dirname, "../data/issues.db");
}

export class DailyRefinementJob {
  constructor(dbPath: string = resolveDbPath()) { ... }
}

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Code style update (formatting, renaming)
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test update

Related Issue

Testing Done

  • Tested locally
  • Added/updated tests
  • All tests passing

Screenshots (if applicable)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Co-Authors


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.


Summary by cubic

Fixes how DailyRefinementJob finds the database by centralizing path resolution and allowing injection. Prevents failures when the working directory differs (local, CI, or cron).

  • Bug Fixes
    • Centralize DB path logic via exported resolveDbPath; constructor now accepts an optional dbPath.
    • Respect DB_PATH env override with a ../data/issues.db fallback for consistency across environments.
    • Add unit tests covering default path and DB_PATH override.

Written for commit cd1aec7. Summary will update on new commits.

…jectable with tests

Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com>
Agent-Logs-Url: https://github.com/RohanExploit/VishwaGuru/sessions/60263ff1-ce6f-4d02-bab7-eeab19d0e8f4
Copilot AI changed the title [WIP] [WIP] Address feedback on database path fix in DailyRefinementJob PR Export resolveDbPath and make DailyRefinementJob DB path injectable with tests Mar 24, 2026
Copilot AI requested a review from RohanExploit March 24, 2026 17:18
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