BARU band: hapus kolom VOTE TERAKHIR + tambah countdown VALID DALAM N HARI (V52) — _edge_rows bawa first_seen_at, filter countdown (first_seen + MATURITY), grid band-list 4 kolom, .valid-in ; image web rebuild + push

This commit is contained in:
proitlab committed 2026-08-08 21:09:01 +07:00
1 parent d6a15a07ae
commit cd1452a353
4 files changed
+49 -10

No files matched your search

+21 -1
View File
@@ -6,6 +6,7 @@ API databisnis dengan cache TTL singkat (V16). Styling per `DESIGN.md`.
Konfigurasi dari env/`.env`.
"""
import math
import time
from datetime import datetime, timedelta, timezone
@@ -78,6 +79,23 @@ def shortdate(value):
return '—'
@app.template_filter('countdown')
def countdown(value, now=None):
"""'VALID DALAM N HARI' utk pemilih BARU (V52).
Maturity = `first_seen_at` + `VEX_MATURITY_DAYS`. Nilai NULL/legacy →
None (⊥ cue). Dihitung utk hari penuh, minimal 1 hari."""
if not value:
return None
try:
valid_at = datetime.fromisoformat(value) + timedelta(days=VEX_MATURITY_DAYS)
except ValueError:
return None
now = now or datetime.now(timezone.utc).replace(tzinfo=None)
days = max(1, math.ceil((valid_at - now).total_seconds() / 86400))
return f'VALID DALAM {days} HARI'
# ————— Jadwal distribusi berikutnya (V38) —————
# Banner BERITA di dashboard menampilkan run distribusi berikutnya. Logika
# boundary sengaja mirror `distribute_loop.next_boundary` (⊥ impor lintas-image,
@@ -316,7 +334,9 @@ def _edge_rows():
if r[2] > exp_cut:
fs = r[4]
if fs is None or fs > new_cut:
new_rows.append(r[:4])
# V52: BARU membawa first_seen_at (elemen ke-4) utk countdown
# `VALID DALAM N HARI` di template.
new_rows.append(r[:4] + (fs,))
else:
expired_rows.append(r[:4])
return new_rows, expired_rows