Skip to content

Low-count alerts for samples with few stored aliquots - #208

Merged
olsonjp merged 1 commit into
mainfrom
low-count-alerts
Nov 11, 2026
Merged

olsonjp merged 1 commit into
mainfrom
low-count-alerts

Conversation

@olsonjp

@olsonjp olsonjp commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Closes #196

What it does

A sample is flagged when it has few stored aliquots left, with two levels and a per-sample off switch, following the consumables low-stock idea.

  • Counting. A sample's count is its aliquots whose disposition is Stored. A box position is not required (most stored aliquots in the lab's data have none), and exhausted, in-use, disposed and soft-deleted aliquots do not count. A sample is an alert at or below the alert level and a warning at or below the warn level ("at or below", as consumables do).
  • Levels. The lab default is warn at 5, alert at 3; the lab has not chosen between 3/5 and 4/6, so this is one setting a lab admin changes in Settings > Low-count alerts (SiteConfiguration.low_count_warn and low_count_alert). A sample can also have its own warn and alert levels, or switch the check off (Sample.low_count_check, low_count_warn, low_count_alert), in its Edit form. An alert level above the warn level is refused; if a sample overrides only one level, the alert level is capped at the warn level.
  • Needs Attention. A new source, Low sample counts, in the attention module from Needs Attention overview, header pill and alert silencing; remove manual alerts #206. It feeds the header pill and the overview page, so it also gets the Silence and Turn back on controls. Silencing a sample means switching its low-count check off. Silenced samples are listed under Silenced and not counted.
  • Samples list. A Stored column with the count and a badge (Alert, Low, or Silenced when the check is off), a Low count · N toggle pill that filters the list, and sorting by stored count.
  • Sample page. Shows the stored count, a badge, and the levels in force.
  • Settings page now displays messages. It never did, so "Site configuration saved." was invisible before. The new levels form is handled separately so saving it does not reset the feature switches (and the reverse).

Decisions to check

Not in this PR

Email notifications (Django email is not configured). The attention module's stable keys (low_count:sample:12) and levels are what an email job should use to avoid repeat alerts.

Migrations

sample/0009_low_count_levels (three fields on Sample) and person/0006_low_count_levels (two fields on SiteConfiguration). All have defaults; no data changes.

Verification

  • sample/tests/test_low_count.py (45 tests): what counts (disposition only, no position needed, soft-deleted ignored, no cross-sample leakage, no-aliquot samples skipped, all-used-up is an alert); the level boundaries and overrides; the attention item text, keys and levels; silence and unsilence through the overview and the endpoint; the pill; the Samples list column, badges, filter, pill and sort; the sample page; the form validation; and the Settings form (admin only, validation, audit log, independence from the feature switches). Existing tests that assumed the old counting rules or an always-empty low-count source are updated. Full suite: 737 tests, OK. makemigrations --check is clean.
  • On the author's local data with the default levels, 4 samples are flagged (all alerts).
  • Not checked by me: how it looks in a browser. In particular the Stored column badge, the Low count pill, the new Settings section, and the plain checkbox for the low-count fields in the sample Edit form.

🤖 Generated with Claude Code

Closes #196.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@olsonjp
olsonjp merged commit 1940e99 into main Nov 11, 2026
1 check passed
@olsonjp
olsonjp deleted the low-count-alerts branch November 11, 2026 17:15
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.

Low-count alerts for samples with few stored aliquots

1 participant