The image build failed on master:
ERROR: Ignored the following versions that require a different python
version: 4.19.0 Requires-Python >=3.11
ERROR: Could not find a version that satisfies the requirement
pymongo==4.19.0
The base image was `python:3.10` but the pinned pymongo 4.19 needs Python
>= 3.11. The image is now `python:3.14-slim` — the current stable release,
so it is not carrying the CVEs fixed in 3.11, 3.12 and 3.13.
All the runtime dependencies ship a cp314 wheel (pymongo included), so no
compiler toolchain is needed. The old apt-get line installed
libsasl2-dev, python-dev-is-python3, libldap2-dev and libssl-dev for
packages that are no longer in the dependency list, so it is gone and the
image is smaller.
The build now asserts the interpreter version, so a base image change that
breaks the pinned requirements fails the build with a clear message rather
than a pip resolution error.
Review findings, all from the independent review of this PR
------------------------------------------------------------
- Mongo indexes: the run metadata is always looked up by `beer_run_id` and
the readings by `(beer_run_id, date)`. Both are now indexed.
- Content-Security-Policy: the app serves only its own vendored assets, so
a strict `default-src 'self'` policy is enforceable. Adding it required
removing the inline `style=` attributes from the templates (they became
`.mb-lg` / `.mt-lg` utility classes) and the one inline `<script> (the run
id now travels as a `data-run-id` attribute). A test asserts no template
has either.
- Job timeouts: the `test` and `build` jobs now have `timeout-minutes`, so
a wedged build stops occupying a runner.
- OG range: raised from 1300 to 1500 points, so a strong specialty brew
(a 1.150 wort is real) can be recorded.
Bugs found and fixed along the way
----------------------------------
- An unfinished run reported a *measured* ABV. `abv_percent()` now returns
None for a run that is still in the fermenter — its figure is a projection,
not a measurement. This was showing the two active runs in the "alcohol by
brew" chart as if they were finished.
- The `/api/runs` endpoints the charts fetch from did not exist, so every
chart was silently empty. They are back, with tests.
- The "brews over time" chart left out the months with no brews, which
spaced the busy months evenly and made the chart read as continuous
activity. The quiet months are now included with a zero.
- The run-detail chart was dropped when PR 1 was scoped down, leaving dead
code behind. It is restored.
Tests: 105 (up from 91).
132 lines
5.5 KiB
HTML
132 lines
5.5 KiB
HTML
{% extends 'base.html' %}
|
|
|
|
{% block title %}Active Beers — Brew Log{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="page__head">
|
|
<div>
|
|
<h1 class="page__title">Active Beers</h1>
|
|
<p class="page__sub">Everything currently in the fermenter, with its tap and projected strength.</p>
|
|
</div>
|
|
<div class="btn-row">
|
|
<a class="btn btn--ghost btn--sm" href="{{ url_for('brews.index') }}">Record a reading</a>
|
|
<a class="btn btn--ghost btn--sm" href="{{ url_for('analysis.history') }}">History</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid--3 mb-lg">
|
|
<div class="stat">
|
|
<div class="stat__label">Active brews</div>
|
|
<div class="stat__value">{{ totals.count }}</div>
|
|
<div class="stat__meta">in the fermenter now</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat__label">Average age</div>
|
|
<div class="stat__value">{{ totals.avg_days }}</div>
|
|
<div class="stat__meta">day{{ '' if totals.avg_days == '1' else 's' }} since first reading</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat__label">Longest running</div>
|
|
<div class="stat__value">{{ totals.longest_days if totals.longest_days is not none else '—' }}</div>
|
|
<div class="stat__meta">day{{ '' if totals.longest_days == 1 else 's' }} in the fermenter</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if cards %}
|
|
<div class="grid grid--cards">
|
|
{% for run in cards %}
|
|
<article class="brew-card">
|
|
<div class="brew-card__head">
|
|
<div>
|
|
<h2 class="brew-card__name">
|
|
<a href="{{ url_for('brews.run_detail', run_id=run.beer_run_id) }}">{{ run.canonical_name }}</a>
|
|
</h2>
|
|
<div class="brew-card__meta">
|
|
Run {{ run.beer_run_id }}
|
|
{% if run.first_date %} · since {{ run.first_date }}{% endif %}
|
|
{% if run.reading_count == 1 %} · 1 reading{% else %} · {{ run.reading_count }} readings{% endif %}
|
|
</div>
|
|
</div>
|
|
{% if run.tap_number is not none %}
|
|
<span class="chip chip--tap">Tap {{ run.tap_number }}</span>
|
|
{% else %}
|
|
<span class="chip chip--active">Active</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="brew-card__stats">
|
|
<div class="brew-card__stat">
|
|
<div class="stat__label">Gravity</div>
|
|
<div class="stat__value">
|
|
{% if run.min_sg is not none %}{{ run.min_sg_decimal }}{% else %}—{% endif %}
|
|
</div>
|
|
{% if run.min_sg is not none %}
|
|
<div class="stat__meta">{{ run.min_sg_point_scale }} points</div>
|
|
{% endif %}
|
|
</div>
|
|
<div class="brew-card__stat">
|
|
<div class="stat__label">Est. ABV</div>
|
|
<div class="stat__value">
|
|
{% if run.projected_abv is not none %}{{ '%.2f' % run.projected_abv }}%{% else %}—{% endif %}
|
|
</div>
|
|
<div class="stat__meta">
|
|
{% if run.projected_abv is not none %}projected{% else %}needs 2nd reading{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="brew-card__stat">
|
|
<div class="stat__label">Days</div>
|
|
<div class="stat__value">
|
|
{% if run.days_in_fermenter is not none %}{{ run.days_in_fermenter }}{% else %}—{% endif %}
|
|
</div>
|
|
<div class="stat__meta">day{{ '' if run.days_in_fermenter == 1 else 's' }} brewing</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if run.readings | length > 1 %}
|
|
<div class="brew-card__spark">
|
|
<canvas class="sparkline"
|
|
data-labels='{{ run.readings | map(attribute="date") | list | tojson }}'
|
|
data-values='{{ run.readings | map(attribute="sg") | list | tojson }}'></canvas>
|
|
</div>
|
|
{% else %}
|
|
<div class="brew-card__spark brew-card__spark--empty faint tiny">
|
|
One reading so far — the trend appears after the next one.
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if run.last_comment %}
|
|
<div class="small muted">
|
|
<strong class="faint tiny">Latest:</strong> {{ run.last_comment }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="btn-row">
|
|
<a class="btn btn--ghost btn--sm"
|
|
href="{{ url_for('brews.run_detail', run_id=run.beer_run_id) }}">Open run</a>
|
|
<a class="btn btn--sm" href="{{ url_for('brews.index') }}">Add reading</a>
|
|
</div>
|
|
</article>
|
|
{% endfor %}
|
|
|
|
{# A tile that fills the last slot and gives the page its missing
|
|
affordance: there is currently no way to start a brew from here. #}
|
|
<a class="brew-card brew-card--new" href="{{ url_for('brews.index') }}">
|
|
<span class="brew-card__new-mark" aria-hidden="true">+</span>
|
|
<span class="brew-card__new-text">
|
|
<strong>Start a new beer</strong>
|
|
<span class="faint tiny">Record its first reading</span>
|
|
</span>
|
|
</a>
|
|
</div>
|
|
{% else %}
|
|
<div class="card">
|
|
<div class="empty">
|
|
<img class="empty__icon" src="{{ url_for('static', filename='img/logo.svg') }}" alt="" width="40" height="40">
|
|
<p><strong>Nothing in the fermenter.</strong></p>
|
|
<p class="small">Start a run by recording its first reading on the
|
|
<a href="{{ url_for('brews.index') }}">brew process page</a>.</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|