feat(qbittorrent): show share ratio for active torrents

This commit is contained in:
Developer
2026-07-21 12:36:03 +00:00
parent 11f093cd2c
commit 0866dc4136
5 changed files with 17 additions and 1 deletions
@@ -17,6 +17,7 @@ interface ActiveTorrent {
direction?: "downloading" | "uploading";
size: number | null;
progress: number | null;
ratio: number | null;
dl_speed: number | null;
up_speed: number | null;
}
@@ -40,6 +41,12 @@ function formatProgress(progress: number | null): string {
return `${Math.round(progress * 100)}% complete`;
}
function formatRatio(ratio: number | null): string {
if (ratio === null || !Number.isFinite(ratio) || ratio < 0)
return "Ratio unknown";
return `Ratio ${ratio.toFixed(2)}`;
}
function formatState(
state: string | null,
direction?: ActiveTorrent["direction"],
@@ -103,7 +110,8 @@ export function QbittorrentActiveTorrentsWidget({
</p>
<p className="text-xs text-muted-foreground">
{formatSize(torrent.size)} ·{" "}
{formatProgress(torrent.progress)}
{formatProgress(torrent.progress)} ·{" "}
{formatRatio(torrent.ratio)}
</p>
</div>
<Badge
@@ -54,6 +54,7 @@ describe("QbittorrentActiveTorrentsWidget", () => {
state: "downloading",
size: 1000,
progress: 0.5,
ratio: 1.25,
dl_speed: 500000,
up_speed: 1000,
},
@@ -77,6 +78,7 @@ describe("QbittorrentActiveTorrentsWidget", () => {
expect(screen.getByText("Show.mkv")).toBeInTheDocument();
expect(screen.getByText("Downloading")).toBeInTheDocument();
expect(screen.getByText("Uploading")).toBeInTheDocument();
expect(screen.getByText(/Ratio 1\.25/)).toBeInTheDocument();
});
it("shows empty state when no active torrents", () => {