Skip to content

Commit

Permalink
Add U/D column calculated as simple ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Sep 25, 2023
1 parent ba086e3 commit c37e831
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/tables/torrenttable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ const AllFields: readonly TableField[] = [
{ name: "haveValid", label: "Have", component: ByteSizeField },
{ name: "downloadedEver", label: "Downloaded", component: ByteSizeField },
{ name: "uploadedEver", label: "Uploaded", component: ByteSizeField },
{
name: "uploadedEver",
label: "U/D",
component: UploadRatioField,
accessorFn: (t) => t.uploadedEver / t.downloadedEver,
columnId: "simpleRatio",
requiredFields: ["uploadedEver", "downloadedEver"] as TorrentFieldsType[],
},
{
name: "percentDone",
label: "Done",
Expand Down Expand Up @@ -203,6 +211,16 @@ function PositiveNumberField(props: TableFieldProps) {
);
}

function UploadRatioField(props: TableFieldProps) {
return (
<div style={{ width: "100%", textAlign: "right" }}>
{props.torrent.downloadedEver === 0
? "∞"
: (props.torrent.uploadedEver / props.torrent.downloadedEver).toFixed(2)}
</div>
);
}

function SeedsField(props: TableFieldProps) {
const sending = props.torrent.peersSendingToUs as number;
const totalSeeds = props.torrent.cachedSeedsTotal;
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const DefaultColumnVisibility: Partial<Record<TableName, VisibilityState>> = {
leftUntilDone: false,
downloadedEver: false,
uploadedEver: false,
simpleRatio: false,
eta: false,
tracker: false,
trackerStatus: false,
Expand Down

0 comments on commit c37e831

Please sign in to comment.