Fix remaining code quality and infrastructure items

- admin.py: remove unused get_current_user import
- feed.py, flock.py, other.py: add IntegrityError handling on POST/PUT
  endpoints; duplicate submissions now return 409 instead of crashing with
  a 500 error
- stats.py: extract magic numbers into named module-level constants
  (DAYS_ROLLING, DAYS_SHORT, PRECISION_AVG, PRECISION_HEN, PRECISION_COST);
  add return type annotations to _total_feed_cost and _total_other_cost;
  normalize both helpers to always return Decimal so budget_stats no longer
  needs Decimal(str(...)) workarounds; simplify _cpe/_cpd helpers
- dashboard.js: read --green CSS variable at runtime instead of hardcoding
  the hex value so chart color stays in sync with the stylesheet
- docker-compose.yml: add healthcheck to api service (polls /api/health
  every 30s) so Docker knows when the API is unhealthy; add password
  strength guidance comment above the db service

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 00:18:58 -07:00
parent ce1e9c5134
commit 9709283d7a
7 changed files with 77 additions and 34 deletions

View File

@@ -35,13 +35,15 @@ function buildChart(eggs) {
if (eggChart) eggChart.destroy(); // prevent duplicate charts on re-render
const green = getComputedStyle(document.documentElement).getPropertyValue('--green').trim();
eggChart = new Chart(ctx, {
type: 'line',
data: {
labels,
datasets: [{
data,
borderColor: '#3d6b4f',
borderColor: green,
backgroundColor: 'rgba(61,107,79,0.08)',
borderWidth: 2,
pointRadius: 3,