-
Notifications
You must be signed in to change notification settings - Fork 36
Fix Refinement Job DB Path #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "date": "2026-03-21", | ||
| "indexScore": 50, | ||
| "delta": 0, | ||
| "topKeywords": [], | ||
| "emergingConcerns": [] | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| "categoryWeights": { | ||||||||||||||||||||||||||||||||||
| "Pothole": 5, | ||||||||||||||||||||||||||||||||||
| "Garbage": 3, | ||||||||||||||||||||||||||||||||||
| "Water Supply": 4, | ||||||||||||||||||||||||||||||||||
| "Streetlight": 2, | ||||||||||||||||||||||||||||||||||
| "Flooding": 8 | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| "duplicateThreshold": 0.84, | ||||||||||||||||||||||||||||||||||
| "lastUpdated": "2026-03-21T19:01:11.261Z", | ||||||||||||||||||||||||||||||||||
| "history": [ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| "date": "2026-03-21", | ||||||||||||||||||||||||||||||||||
| "categoryWeights": { | ||||||||||||||||||||||||||||||||||
| "Pothole": 5, | ||||||||||||||||||||||||||||||||||
| "Garbage": 3, | ||||||||||||||||||||||||||||||||||
| "Water Supply": 4, | ||||||||||||||||||||||||||||||||||
| "Streetlight": 2, | ||||||||||||||||||||||||||||||||||
| "Flooding": 8 | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| "duplicateThreshold": 0.85 | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+23
|
||||||||||||||||||||||||||||||||||
| "lastUpdated": "2026-03-21T19:01:11.261Z", | |
| "history": [ | |
| { | |
| "date": "2026-03-21", | |
| "categoryWeights": { | |
| "Pothole": 5, | |
| "Garbage": 3, | |
| "Water Supply": 4, | |
| "Streetlight": 2, | |
| "Flooding": 8 | |
| }, | |
| "duplicateThreshold": 0.85 | |
| } | |
| ] | |
| "lastUpdated": "1970-01-01T00:00:00.000Z", | |
| "history": [] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,7 +8,7 @@ import { Issue } from "../services/types"; | |||||
|
|
||||||
| // Load environmental or fallback to test.db or production db | ||||||
|
||||||
| // Load environmental or fallback to test.db or production db | |
| // Use DB_PATH environment variable if set; otherwise fall back to data/issues.db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the relative path resolution is correct
# From scheduler/ directory, ../data/issues.db should resolve to data/issues.db
echo "=== Checking directory structure ==="
fd -t d -d 1 "^(scheduler|data)$" .
echo -e "\n=== Verifying Python backend default paths ==="
rg -n "issues\.db" backend/Repository: RohanExploit/VishwaGuru
Length of output: 547
🏁 Script executed:
cat -n scheduler/dailyRefinementJob.ts | head -40Repository: RohanExploit/VishwaGuru
Length of output: 1775
🏁 Script executed:
rg -n "DATABASE_URL|dbPath" scheduler/ -A 3 -B 1Repository: RohanExploit/VishwaGuru
Length of output: 1044
🏁 Script executed:
fd -t f "\.(ts|js)$" scheduler/ | head -10Repository: RohanExploit/VishwaGuru
Length of output: 98
🏁 Script executed:
rg -n "production|Production|PROD" scheduler/ backend/ | head -20Repository: RohanExploit/VishwaGuru
Length of output: 1773
🏁 Script executed:
fd -t f "\.(md|txt)$" . -path "*/scheduler/*" -o -path "*/docs/*"Repository: RohanExploit/VishwaGuru
Length of output: 235
🏁 Script executed:
cat -n backend/README.md | grep -A 5 -B 5 "scheduler\|DATABASE_URL" | head -40Repository: RohanExploit/VishwaGuru
Length of output: 1426
Path fix is correct, but scheduler's hardcoded SQLite creates a production issue with Postgres deployments.
The updated path ../data/issues.db correctly aligns with the Python backend's SQLite default (sqlite:///./data/issues.db in backend/database.py and backend/config.py).
However, the scheduler hardcodes sqlite3 and only respects DB_PATH environment variable, completely ignoring DATABASE_URL. The backend explicitly supports both SQLite (development) and PostgreSQL (production), but the scheduler will always use local SQLite regardless of the backend's database choice. In production with Postgres, this scheduler will operate on stale or empty data.
Consider:
- Refactor the scheduler to support
DATABASE_URLfor Postgres connections, or - Document that the scheduler is SQLite-only and production setups must not rely on it with Postgres backends.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scheduler/dailyRefinementJob.ts` around lines 10 - 11, The scheduler
currently hardcodes SQLite via the dbPath constant and ignores DATABASE_URL,
causing it to run against a local DB while the backend may use Postgres; change
the scheduler (scheduler/dailyRefinementJob.ts) to detect
process.env.DATABASE_URL and branch: if DATABASE_URL is present and begins with
"postgres" use a Postgres client (e.g., node-postgres) to connect and run the
same queries/transactions the scheduler uses, otherwise fall back to the
existing sqlite logic using dbPath; ensure connection creation/teardown mirrors
backend behavior (pool vs file DB) and that any SQL differences are handled, or
alternatively update README to explicitly document that the scheduler is
SQLite-only and must not be used in Postgres production deployments.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { DailyRefinementJob } from './scheduler/dailyRefinementJob'; | ||
| const job = new DailyRefinementJob(); | ||
| job.runRefinement().then(() => { | ||
| console.log("Done"); | ||
| process.exit(0); | ||
| }); | ||
|
Comment on lines
+1
to
+6
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a daily, date-stamped output artifact from IntelligenceIndex.saveSnapshot(). Checking in per-day snapshots will grow the repo over time and cause frequent merge conflicts/stale data. Consider removing this file from the PR and adding data/dailySnapshots/*.json to .gitignore (or keep snapshots in an external/persistent volume only).