Dashboard: move Recent Activity under Playlist Overview and split out heartbeats

Moves the Recent Activity card into the main column, directly beneath
Playlist Overview, so the two cards that describe "what the server and
its players are doing" sit together. System Status stays full-width below
the grid.

While moving it, the card was showing almost nothing useful: player
feedback ("Feedback received from ...") is a ~15s heartbeat that makes up
84% of all log rows (423/506) and 18 of the newest 20, so the list was a
wall of repeated one-line status reports that pushed real events off the
screen.

The card is now tabbed:
  - "Activity" (default) - uploads, logins, HTTPS changes, deployments...
  - "Player heartbeats"  - the raw status stream, on demand

get_recent_logs() gains exclude_prefix / include_prefix so the split
happens in SQL. Filtering a single wide window in Python instead gave only
7 useful entries, because the number returned depends on heartbeat volume
and would fall further as more players are added. Both queries now return
25. Prefixes are passed with autoescape=True so a literal '%' or '_' in a
prefix matches itself rather than acting as a LIKE wildcard.

UI: the list is capped at 320px and scrolls, so a long log cannot make
the card dominate the page. Long messages wrap instead of pushing the
timestamp off-screen (previously float:right), and the debug level now
has its own colour instead of rendering as "info" green.

Verified: 25/25 entries per tab, no cross-contamination, no horizontal
overflow at 500-1400px, tabs wrap below the title under ~600px, and dark
mode uses the theme variables.
This commit is contained in:
2026-09-11 15:42:45 +03:00
parent 84b5cd3d48
commit b4c3f65636
3 changed files with 188 additions and 24 deletions
+25 -4
View File
@@ -23,21 +23,42 @@ def log_action(level: str, message: str) -> None:
db.session.rollback()
def get_recent_logs(limit: int = 20, level: Optional[str] = None) -> list:
def get_recent_logs(limit: int = 20, level: Optional[str] = None,
exclude_prefix: Optional[str] = None,
include_prefix: Optional[str] = None) -> list:
"""Get the most recent log entries.
Args:
limit: Maximum number of logs to return
level: Optional filter by log level
exclude_prefix: Drop entries whose message starts with this text.
Useful for high-frequency noise: player feedback alone is ~84% of
all rows, so over-fetching a window and filtering in Python makes
the number of *useful* entries depend on heartbeat volume. Filtering
in SQL keeps a busy fleet from starving the result.
include_prefix: Keep only entries whose message starts with this text.
Returns:
List of ServerLog instances
List of ServerLog instances, newest first
Note:
Prefixes are escaped before reaching SQL LIKE (via ``autoescape``), so a
literal '%' or '_' inside the prefix matches itself rather than acting
as a wildcard.
"""
query = ServerLog.query
if level:
query = query.filter_by(level=level)
if exclude_prefix:
query = query.filter(
~ServerLog.message.startswith(exclude_prefix, autoescape=True))
if include_prefix:
query = query.filter(
ServerLog.message.startswith(include_prefix, autoescape=True))
return query.order_by(ServerLog.timestamp.desc()).limit(limit).all()