|
|
|
@ -14,6 +14,27 @@ DEFAULT_ACTOR = os.environ.get("SPLITBUDDY_ACTOR", "anon") # who is using this
|
|
|
|
DEFAULT_A_SHARE_PCT = os.environ.get("SPLITBUDDY_DEFAULT_A_SHARE_PCT", 66.6667) # <-- you pay 2/3 by default
|
|
|
|
DEFAULT_A_SHARE_PCT = os.environ.get("SPLITBUDDY_DEFAULT_A_SHARE_PCT", 66.6667) # <-- you pay 2/3 by default
|
|
|
|
WEBAPP_PORT = os.environ.get("SPLITBUDDY_WEBAPP_PORT", 42069)
|
|
|
|
WEBAPP_PORT = os.environ.get("SPLITBUDDY_WEBAPP_PORT", 42069)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Template filters -----
|
|
|
|
|
|
|
|
@app.template_filter('human_time')
|
|
|
|
|
|
|
|
def human_time(value: Any) -> str:
|
|
|
|
|
|
|
|
"""Format ISO-ish timestamps into a concise human-readable string.
|
|
|
|
|
|
|
|
Accepts values like '2025-09-14T18:37' or '2025-09-14T18:37:00Z'.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not value:
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if isinstance(value, dt.datetime):
|
|
|
|
|
|
|
|
d = value
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
s = str(value).strip()
|
|
|
|
|
|
|
|
# fromisoformat doesn't accept trailing 'Z' (UTC); strip it if present
|
|
|
|
|
|
|
|
if s.endswith('Z'):
|
|
|
|
|
|
|
|
s = s[:-1]
|
|
|
|
|
|
|
|
d = dt.datetime.fromisoformat(s)
|
|
|
|
|
|
|
|
return d.strftime("%b %d, %Y %H:%M")
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
return str(value)
|
|
|
|
|
|
|
|
|
|
|
|
# ----- DB helpers -----
|
|
|
|
# ----- DB helpers -----
|
|
|
|
def get_db() -> sqlite3.Connection:
|
|
|
|
def get_db() -> sqlite3.Connection:
|
|
|
|
if "db" not in g:
|
|
|
|
if "db" not in g:
|
|
|
|
|