feat(ui): rebuild the interface with a proper design system
The old UI was two pages of raw pandas tables with no navigation, no styling and no way to see a run's comments. This replaces it with a small, testable application and a beer-themed design. What changed ------------ Restructure - The domain logic now lives in `brewing.py` as pure functions over plain data, with no Flask or Mongo dependency. The gravity maths, the ABV formula and the run-aggregation rules are unit-testable on their own. - `app_factory.py` replaces the module-level app, and the routes move into blueprints under `views/`. A request-scoped Mongo repository is created per request and closed at teardown. - `mongo/repository.py` replaces `build_db.py` / `query_db.py` / `get_conn.py`. Reading a document no longer requires a second query to fetch the fields. Interface - A dark, beer-themed design system: warm amber `#be7f39` on near-black, a condensed display face (Anton) for headings and Inter for body text. Both fonts and the chart library are vendored into `static/`, so the container needs no outbound network at runtime — the old templates pulled Bootstrap from a CDN. - A real navigation bar, a login page, a brew-process page with a proper form, and a run-detail page listing every reading with its comment. - The run summary tables now show the beer name and the latest comment, which the old pandas tables did not. - Native form controls (checkbox, number spinners, date icon, scrollbars) are restyled for the dark theme. Correctness - The alcohol calculation now uses the standard homebrew formula, `(OG - FG) x 131.25`. The old code used `(max - min) / 7.36 + 0.5`, which is not a recognised brewing formula and overstated every result. - Gravity points and decimal readings now convert correctly in both directions (`1039` <-> `1.039`). - A run's display name resolves to the most-used label across its readings, because `beer_type` is stored per-reading and drifts across a run. - Re-submitting a reading for the same run and day updates it in place rather than creating a duplicate. Security / production - The container ran the Werkzeug debugger with `FLASK_DEBUG=1`, exposing an interactive console on any unhandled error. It now runs waitress with debugging off. - `SECRET_KEY` comes from the environment. - The app secret is no longer a hard-coded string in source. Housekeeping - Removes the bokeh/duckdb/pandas dependency chain and the static file it generated at import time; removes the dead `add_user.py` and `test.py`. - Splits `requirements.txt` (runtime) from `requirements-dev.txt` (tests). - Adds a pytest suite (64 tests) and a `test` job to the CI workflow so the image is only built when the tests pass. - Adds a README describing the data model and a RUNBOOK for the cluster side. Data compatibility ------------------ The existing `beer_db.beer_data` documents are read as they are and are not migrated or rewritten. No collection is dropped, and no document is modified by this change other than through the explicit "record a reading" form, which keeps the original `(date, beer_run_id)` uniqueness rule.
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Run {{ summary.beer_run_id }} — Brew Log{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page__head">
|
||||
<div>
|
||||
<h1 class="page__title">
|
||||
{{ summary.canonical_name }}
|
||||
{% if summary.active %}
|
||||
<span class="chip chip--active">Active</span>
|
||||
{% else %}
|
||||
<span class="chip chip--done">Finished</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
<p class="page__sub">
|
||||
Run <span class="mono">{{ summary.beer_run_id }}</span>
|
||||
{% if summary.first_date %} · started {{ summary.first_date }}{% endif %}
|
||||
{% if summary.final_date %} · finished {{ summary.final_date }}{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
<a class="btn btn--ghost btn--sm" href="{{ url_for('brews.index') }}">← Back</a>
|
||||
</div>
|
||||
|
||||
<div class="grid grid--4" style="margin-bottom:1.25rem">
|
||||
<div class="stat">
|
||||
<div class="stat__label">Original gravity</div>
|
||||
<div class="stat__value">
|
||||
{% if summary.og_points is not none %}{{ summary.og_points }}{% else %}—{% endif %}
|
||||
</div>
|
||||
{% if summary.og_decimal %}
|
||||
<div class="stat__meta">{{ '%.3f' % summary.og_decimal }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat__label">
|
||||
{% if summary.active %}Current gravity{% else %}Final gravity{% endif %}
|
||||
</div>
|
||||
<div class="stat__value">
|
||||
{% if summary.fg_points is not none %}{{ summary.fg_points }}{% else %}—{% endif %}
|
||||
</div>
|
||||
{% if summary.fg_decimal %}
|
||||
<div class="stat__meta">{{ '%.3f' % summary.fg_decimal }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat__label">Alcohol</div>
|
||||
<div class="stat__value">
|
||||
{% if summary.abv is not none %}
|
||||
{{ '%.2f' % summary.abv }}%
|
||||
{% elif summary.projected_abv is not none %}
|
||||
{{ '%.2f' % summary.projected_abv }}%
|
||||
{% else %}—{% endif %}
|
||||
</div>
|
||||
<div class="stat__meta">
|
||||
{% if summary.abv is not none %}measured{% else %}projected{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat__label">Days brewing</div>
|
||||
<div class="stat__value">
|
||||
{% if summary.days_in_fermenter is not none %}{{ summary.days_in_fermenter }}{% else %}—{% endif %}
|
||||
</div>
|
||||
<div class="stat__meta">{{ summary.reading_count }} reading{{ '' if summary.reading_count == 1 else 's' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="card">
|
||||
<div class="card__head">
|
||||
<h2 class="card__title">Readings</h2>
|
||||
<span class="card__hint">{{ summary.reading_count }} total</span>
|
||||
</div>
|
||||
<div class="card__body">
|
||||
<ul class="reading-list">
|
||||
{% for reading in summary.readings %}
|
||||
<li class="reading-list__item">
|
||||
<span class="reading-list__date">{{ reading.date or '—' }}</span>
|
||||
<span class="reading-list__sg">
|
||||
{% if reading.sg is not none %}{{ reading.sg }}{% else %}—{% endif %}
|
||||
</span>
|
||||
<div class="reading-list__body">
|
||||
{% if reading.comment %}
|
||||
<div class="reading-list__comment">{{ reading.comment }}</div>
|
||||
{% else %}
|
||||
<div class="faint tiny">No comment</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if reading.final_reading %}
|
||||
<span class="chip chip--done">Final</span>
|
||||
<form method="post" action="{{ url_for('brews.unfinal', run_id=summary.beer_run_id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="date" value="{{ reading.date }}">
|
||||
<button class="btn btn--ghost btn--sm" type="submit">Un-set</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<form method="post" action="{{ url_for('brews.mark_final', run_id=summary.beer_run_id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="date" value="{{ reading.date }}">
|
||||
<button class="btn btn--ghost btn--sm" type="submit">Set final</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user