Skip to content

Fix Database Path in DailyRefinementJob#574

Open
RohanExploit wants to merge 1 commit intomainfrom
fix-daily-refinement-db-path-12076064593165869744
Open

Fix Database Path in DailyRefinementJob#574
RohanExploit wants to merge 1 commit intomainfrom
fix-daily-refinement-db-path-12076064593165869744

Conversation

@RohanExploit
Copy link
Owner

@RohanExploit RohanExploit commented Mar 22, 2026

Fixes dbPath fallback to point to ../data/issues.db. Adds ts-jest to allow npm test to pass.


PR created automatically by Jules for task 12076064593165869744 started by @RohanExploit


Summary by cubic

Fix the fallback database path in DailyRefinementJob to ../data/issues.db so the job reads the correct DB when DB_PATH isn’t set. Update test tooling (ts-jest, @types/jest, jest-util) to ensure npm test runs successfully.

Written for commit 4737b22. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Updated Jest-related development dependencies to latest patch versions.
    • Adjusted database configuration path for improved system consistency.

@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings March 22, 2026 18:58
@netlify
Copy link

netlify bot commented Mar 22, 2026

Deploy Preview for fixmybharat canceled.

Name Link
🔨 Latest commit 4737b22
🔍 Latest deploy log https://app.netlify.com/projects/fixmybharat/deploys/69c03be4d25f1c0008a52b56

@github-actions
Copy link

🙏 Thank you for your contribution, @RohanExploit!

PR Details:

Quality Checklist:
Please ensure your PR meets the following criteria:

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Code is commented where necessary
  • Documentation updated (if applicable)
  • No new warnings generated
  • Tests added/updated (if applicable)
  • All tests passing locally
  • No breaking changes to existing functionality

Review Process:

  1. Automated checks will run on your code
  2. A maintainer will review your changes
  3. Address any requested changes promptly
  4. Once approved, your PR will be merged! 🎉

Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

Jest development dependencies updated to newer versions. Additionally, the SQLite database fallback path in DailyRefinementJob was changed from a backend directory reference to a local data directory path when DB_PATH environment variable is not set.

Changes

Cohort / File(s) Summary
Dependency Updates
package.json
Updated Jest-related dev dependencies: @types/jest to ^29.5.14, jest-util to ^30.3.0, and ts-jest to ^29.4.6.
Database Configuration
scheduler/dailyRefinementJob.ts
Modified SQLite database fallback path from scheduler/../../backend/app.db to scheduler/../data/issues.db when DB_PATH environment variable is not configured.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Hopping through versions with jest so fine,
New paths to data, all in a line,
Dependencies dance, databases shift,
Our testing tools gift, a stable uplift!
Nibble by nibble, we refine the way,
Scheduler's on track for a better day! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and lacks required template sections like Type of Change, Related Issue, Testing Done, and Checklist. Add the missing template sections: specify the Type of Change (appears to be a bug fix), fill in the Related Issue field with the task reference, document Testing Done, and complete the pre-merge Checklist.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing the database path in DailyRefinementJob, which is the primary modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-daily-refinement-db-path-12076064593165869744

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Node-based scheduler job to use the repository’s data/issues.db SQLite database by default and adjusts Jest/TypeScript testing dependencies so npm test runs successfully.

Changes:

  • Fix DailyRefinementJob SQLite fallback path to data/issues.db.
  • Update Jest/TypeScript-related devDependencies (notably @types/jest, ts-jest, jest-util).
  • Regenerate package-lock.json to reflect dependency updates.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
scheduler/dailyRefinementJob.ts Points the scheduler’s default SQLite DB to ../data/issues.db (repo data/issues.db).
package.json Bumps Jest typing + ts-jest and updates jest-util version.
package-lock.json Lockfile updates reflecting the dependency changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -8,7 +8,7 @@ import { Issue } from "../services/types";

// Load environmental or fallback to test.db or production db
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above dbPath is now misleading: the fallback is no longer a test DB or backend/app.db—it resolves to ../data/issues.db (and can be overridden via DB_PATH). Please update the comment to match the actual behavior to avoid confusion during ops/debugging.

Suggested change
// Load environmental or fallback to test.db or production db
// Use DB_PATH env var if set, otherwise fall back to ../data/issues.db

Copilot uses AI. Check for mistakes.
Comment on lines 10 to +11
const dbPath =
process.env.DB_PATH || path.join(__dirname, "../../backend/app.db");
process.env.DB_PATH || path.join(__dirname, "../data/issues.db");
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes the default SQLite path, but there’s no test that would fail if this regressed (e.g., asserting what path is used when DB_PATH is unset). Consider making the path derivation injectable/exported and adding a focused Jest test so the intended default (data/issues.db) is enforced.

Copilot uses AI. Check for mistakes.
Comment on lines 32 to +35
"jest": "^29.7.0",
"jest-environment-jsdom": "^30.3.0",
"jest-util": "^30.2.0",
"ts-jest": "^29.1.2",
"jest-util": "^30.3.0",
"ts-jest": "^29.4.6",
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jest-related devDependencies are now a mix of Jest v29 (jest) and Jest v30 packages (jest-environment-jsdom, jest-util). This pulls Jest 30 internals into the lockfile and can cause subtle resolver/version skew. Prefer aligning all Jest packages to the same major version (or removing jest-util/jest-environment-jsdom if they aren’t needed for this repo’s Jest config).

Copilot uses AI. Check for mistakes.
"jest-util": "^30.2.0",
"ts-jest": "^29.1.2",
"jest-util": "^30.3.0",
"ts-jest": "^29.4.6",
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says "Adds ts-jest" but ts-jest was already present; this change is a version bump. Please adjust the PR description (or commit message) so it accurately reflects what changed.

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Around line 34-35: The project mixes Jest major versions: core "jest" is
29.7.0 while "jest-util" and "jest-environment-jsdom" are 30.x; align them by
either upgrading "jest" and "ts-jest" to 30.x or downgrading "jest-util" and
"jest-environment-jsdom" to 29.x to match "jest" 29.7.0; specifically update the
package.json entries for "jest", "jest-util", "jest-environment-jsdom", and
"ts-jest" so all share the same major version, then reinstall dependencies and
run the test suite to verify compatibility.

In `@scheduler/dailyRefinementJob.ts`:
- Line 11: The code computes the DB path using process.env.DB_PATH ||
path.join(__dirname, "../data/issues.db") but may attempt to open the SQLite
file before its parent directory exists; before calling new
sqlite3.Database(...) ensure the directory for that computed dbPath exists (use
path.dirname(dbPath) and create it with recursive mkdir), then proceed to open
the database so new sqlite3.Database(...) won't fail on fresh environments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc06957d-facd-4a90-9242-e0f66f5961d9

📥 Commits

Reviewing files that changed from the base of the PR and between c73144f and 4737b22.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json
  • scheduler/dailyRefinementJob.ts

Comment on lines +34 to +35
"jest-util": "^30.3.0",
"ts-jest": "^29.4.6",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

For Jest 29.7.0, what are the officially supported versions (or required major versions) of ts-jest, jest-util, and jest-environment-jsdom?

💡 Result:

For Jest 29.7.0: - ts-jest: major version 29 (e.g., ^29.0.0 to ^29.4.6), as ts-jest follows Jest's major version numbering and explicitly supports Jest ^29.0.0 || ^30.0.0 in its peer dependencies. - jest-util: ^29.7.0 (same major.minor as Jest core packages). - jest-environment-jsdom: ^29.7.0 (same major.minor as Jest core packages; version 29.7.0 exists and depends on jest-util among other ^29 packages).

Citations:


🏁 Script executed:

cat package.json | head -40

Repository: RohanExploit/VishwaGuru

Length of output: 1108


Align Jest ecosystem packages to the same major version.

The project uses jest 29.7.0 but has jest-util and jest-environment-jsdom at 30.x while ts-jest remains at 29.4.6. Mixing Jest major versions across the ecosystem commonly causes test failures and configuration conflicts. Either upgrade all packages to 30.x or downgrade jest-util and jest-environment-jsdom to 29.x to match the core jest dependency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 34 - 35, The project mixes Jest major versions:
core "jest" is 29.7.0 while "jest-util" and "jest-environment-jsdom" are 30.x;
align them by either upgrading "jest" and "ts-jest" to 30.x or downgrading
"jest-util" and "jest-environment-jsdom" to 29.x to match "jest" 29.7.0;
specifically update the package.json entries for "jest", "jest-util",
"jest-environment-jsdom", and "ts-jest" so all share the same major version,
then reinstall dependencies and run the test suite to verify compatibility.

// Load environmental or fallback to test.db or production db
const dbPath =
process.env.DB_PATH || path.join(__dirname, "../../backend/app.db");
process.env.DB_PATH || path.join(__dirname, "../data/issues.db");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Create the fallback directory before opening the SQLite file.

This path fix is good, but it can still fail on fresh environments if ../data doesn’t exist. Ensure the parent directory exists before new sqlite3.Database(...) is called.

Suggested patch
 import * as cron from "node-cron";
 import * as sqlite3 from "sqlite3";
 import * as path from "path";
+import * as fs from "fs";
 import { TrendAnalyzer } from "../services/trendAnalyzer";
 import { AdaptiveWeights } from "../services/adaptiveWeights";
 import { IntelligenceIndex } from "../services/intelligenceIndex";
 import { Issue } from "../services/types";

 // Load environmental or fallback to test.db or production db
 const dbPath =
   process.env.DB_PATH || path.join(__dirname, "../data/issues.db");
+fs.mkdirSync(path.dirname(dbPath), { recursive: true });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scheduler/dailyRefinementJob.ts` at line 11, The code computes the DB path
using process.env.DB_PATH || path.join(__dirname, "../data/issues.db") but may
attempt to open the SQLite file before its parent directory exists; before
calling new sqlite3.Database(...) ensure the directory for that computed dbPath
exists (use path.dirname(dbPath) and create it with recursive mkdir), then
proceed to open the database so new sqlite3.Database(...) won't fail on fresh
environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants