Skip to content

SABnzbd/NZBGet: show recent history inline on the downloads page - #100

Open
ndandan wants to merge 3 commits into
Shoshuo:mainfrom
ndandan:pr/usenet-recent-history
Open

SABnzbd/NZBGet: show recent history inline on the downloads page#100
ndandan wants to merge 3 commits into
Shoshuo:mainfrom
ndandan:pr/usenet-recent-history

Conversation

@ndandan

@ndandan ndandan commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #47.

Adds a server-rendered Recent history section (latest 15, compact one-line rows: name + category/status/size pills + a new age pill) below the queue on the downloads page, with a "View all" link to the full paginated history page. Works for both SABnzbd and NZBGet.

Implementation notes:

  • UsenetDownload gains a nullable completedAt epoch, mapped from SABnzbd's completed and NZBGet's HistoryTime; the age pill renders via the existing relative_date filter and falls back to an em dash when unknown. (This also adds the age line to the history page itself.)
  • The history rows are extracted into a shared _history_rows.html.twig partial; the .uh-* CSS moves to _history_styles.html.twig, included from both pages' stylesheets block.
  • The recent-history fetch sits behind a 45s per-client cache (empty results and failures aren't cached). This matters for NZBGet, where getHistoryPage() is a full-history RPC transfer sliced locally — without the cache every downloads-page render would re-transfer the entire retained history. The paginated history page stays uncached/live.
  • On a failed fetch the section simply doesn't render (the page keeps its normal error banners).

Tests: completedAt mapping units for both clients; render, arg-pinning (->with(0, 15)), cache short-circuit (two renders → one client call), and error-path functional tests. 48 tests / 132 assertions green, lint:twig + lint:yaml clean, EN+FR keys included.

🤖 Generated with Claude Code

ndandan and others added 3 commits August 22, 2026 20:03
History entries knew *what* finished but never *when*. Add a nullable
`completedAt` unix epoch to UsenetDownload and map it in both clients:
SABnzbd's history slot `completed`, NZBGet's history entry `HistoryTime`
(the epoch the job landed in history). Absent or 0 stays null so the UI
never renders a 1970 date.

Queue slots leave it null — only history carries a finish time.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ream Shoshuo#47

The downloads page showed the live queue only: once a job finished it
vanished, and answering "did that grab actually land?" meant a trip to the
dedicated history page. Add a "Recent history" section under the queue —
the last 15 entries, server-rendered at page load (no poller: history
doesn't move on its own), each row showing its finish age, plus a
"View all (N)" link into the paginated page.

The row loop moves verbatim from history.html.twig into a shared
_history_rows.html.twig partial, which also carries the .uh-* CSS so both
pages get it from the single include instead of duplicating the block.
Both pages gain the relative-age line from the new completedAt field.

index() skips the fetch when the render-time probe already failed (the
page shows its unreachable banner) and swallows any client error into an
empty list, so a broken downloader never takes the page with it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…heet blocks

Two review follow-ups on the Shoshuo#47 preview.

1. NZBGet's history RPC has no upstream paging — getHistoryPage() pulls the
   whole retained history (Parameters, ScriptStatuses, per-server ServerStats
   and all) and slices locally, so the new per-render fetch was an unbounded
   transfer on that client. Wrap it in a short per-client cache
   (usenet.recent_history.<client>, 45s — MediaLibraryCache's window), so
   repeat renders inside the window cost nothing upstream. No invalidation
   needed: history only grows when a job finishes. An empty result expires
   immediately and a throwing fetch caches nothing, so neither a fresh install
   nor a transient failure is pinned for the window. The paginated history
   page is untouched — it stays live and user-driven.

2. The .uh-* rules move out of the body-level <style> in the rows partial into
   _history_styles.html.twig, included from the {% block stylesheets %} of both
   usenet pages — the repo's own dashboard/_plex_styles.html.twig idiom, and
   conforming HTML. The rows partial is markup only now.

Tests pin the fetch window (with(0, 15)), the cache short-circuit (two renders,
one client call — which also proves the UsenetDownload DTOs survive the pool
round-trip) and the retry-after-failure behaviour. The class clears both
clients' cache keys in setUp() so the filesystem pool can't leak state between
tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] SabNZBD UI Improvements

1 participant