• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FlexMeasures / flexmeasures / 30824372247
83%
main: 84%

Build:
Build:
LAST BUILD BRANCH: feat/internal-commodity-balance
DEFAULT BRANCH: main
Ran 03 Aug 2026 03:02PM UTC
Jobs 1
Files 173
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

03 Aug 2026 02:47PM UTC coverage: 83.466%. Remained the same
30824372247

push

github

Flix6x
Summarise which sources recorded for which sensors

Two mirrored accessors ask which data sources have recorded for which sensors:
Sensor.data_sources reads timed_belief in sensor_id order,
DataSource.sensors reads it in source_id order.
Both answer a question about a relation bounded by sensors times sources,
a few thousand rows at most,
by reading the largest table in the database.

Reordering the primary key to lead with sensor_id (d4a7c1e93b52) makes the second one
worse: nothing leads with source_id any more, so it degrades to a sequential scan.
An index on source_id would fix that, but at a large fraction of what that migration
reclaims, to answer a question about a few thousand rows.

Add a sensor_data_source summary table instead, keyed on the pair.
It serves both accessors as a plain lookup,
so it also removes the sensor-leading one's dependence on scanning beliefs.

Maintained by a statement-level trigger rather than from the save path.
That was not the first design: the hook originally lived in TimedBelief.add_to_session,
on the reasoning that every save funnels through it.
Two existing tests then failed with empty results,
because they insert beliefs without going through that path -- and so do bulk inserts,
COPY, plugins and raw SQL.
A hook would have left the summary silently incomplete in exactly the cases nobody
checks, so the trigger does it instead: unbypassable whatever the insert route,
and one small upsert per statement rather than per row.
A test inserts through raw SQL specifically to pin that.

The trigger and its function are created both by the migration and by a create_all
DDL listener, so a schema built either way behaves the same.
Both are written idempotently, since create_all runs once per test module.

The summary is deliberately a superset:
pairs are added on insert and not removed on delete,
because deciding whether a pair went stale needs exactly the scan this avoids.
Sensor.search_data_sources still reads timed_beli... (continued)

11 of 12 new or added lines in 2 files covered. (91.67%)

16603 of 19892 relevant lines covered (83.47%)

0.83 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
88.99
-0.2% flexmeasures/data/models/data_sources.py
Jobs
ID Job ID Ran Files Coverage
1 30824372247.1 03 Aug 2026 03:01PM UTC 173
83.47
GitHub Action Run
Source Files on build 30824372247
  • Tree
  • List 173
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #30824372247
  • 669dd381 on github
  • Prev Build on feat/timed-belief-pk-column-order (#30823606127)
  • Next Build on feat/sensor-data-source-association (#30824436689)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc