forked from jordanlambrecht/tracker-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransforms.ts
More file actions
37 lines (34 loc) · 1.05 KB
/
Copy pathtransforms.ts
File metadata and controls
37 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// src/lib/download-clients/transforms.ts
import type { TorrentRecord } from "./types"
/**
* Maps a full TorrentRecord (normalized camelCase) to the 23-field shape stored in cachedTorrents JSONB.
* The resulting shape matches TorrentRaw from fleet.ts sans clientName (stamped at query time).
*/
export type SlimTorrent = ReturnType<typeof slimTorrentForCache>
export function slimTorrentForCache(t: TorrentRecord) {
return {
hash: t.hash,
name: t.name,
state: t.state,
tags: t.tags,
category: t.category,
uploaded: t.uploaded,
downloaded: t.downloaded,
ratio: t.ratio,
size: t.size,
seedingTime: t.seedingTime,
activeTime: t.activeTime,
addedAt: t.addedAt,
completedAt: t.completedAt,
lastActivityAt: t.lastActivityAt,
remaining: t.remaining,
seedCount: t.seedCount,
leechCount: t.leechCount,
swarmSeeders: t.swarmSeeders,
swarmLeechers: t.swarmLeechers,
uploadSpeed: t.uploadSpeed,
downloadSpeed: t.downloadSpeed,
availability: t.availability,
progress: t.progress,
}
}