Skip to content

fix(parser): pass user_id to stats DBWriter in main#50

Merged
cchwala merged 2 commits into
mainfrom
fix/parser-stats-user-id
May 18, 2026
Merged

fix(parser): pass user_id to stats DBWriter in main#50
cchwala merged 2 commits into
mainfrom
fix/parser-stats-user-id

Conversation

@cchwala
Copy link
Copy Markdown
Member

@cchwala cchwala commented May 18, 2026

The stats background thread was instantiated as DBWriter(Config.DATABASE_URL), omitting user_id. It silently defaulted to 'demo_openmrg'. refresh_stats() uses self.user_id both as the argument to update_cml_stats() and as the WHERE filter on cml_metadata, so stats were never computed for any user other than demo_openmrg — causing map line colouring to show no colour for all other users' CMLs.

Fix: DBWriter(Config.DATABASE_URL, user_id=Config.USER_ID).

The stats background thread was instantiated without user_id, so it
defaulted to 'demo_openmrg'.  refresh_stats() uses self.user_id both
as the argument to update_cml_stats() and as the WHERE filter on
cml_metadata, meaning stats were never computed for any other user
(CTU, Orange Cameroun) — causing map line colouring to show no colour
for their CMLs.

Fix: pass user_id=Config.USER_ID so each parser instance refreshes
stats for its own user.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.08%. Comparing base (d5cee5d) to head (8632806).

Files with missing lines Patch % Lines
parser/tests/test_main.py 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #50      +/-   ##
==========================================
+ Coverage   82.63%   85.08%   +2.45%     
==========================================
  Files          28       24       -4     
  Lines        2920     2575     -345     
==========================================
- Hits         2413     2191     -222     
+ Misses        507      384     -123     
Flag Coverage Δ
mno_simulator 86.12% <ø> (ø)
parser 91.15% <90.90%> (+2.27%) ⬆️
scripts ?
webserver 67.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cchwala cchwala merged commit efc16a8 into main May 18, 2026
7 checks passed
@cchwala cchwala deleted the fix/parser-stats-user-id branch May 18, 2026 20:29
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.

1 participant