Sort repair queue

This commit is contained in:
Ben Adrian Sarmiento
2024-06-24 17:22:43 +02:00
parent 4049fa7d83
commit 08867d8fea

View File

@@ -29,7 +29,7 @@ type RootResponse struct {
UserInfo *realdebrid.User `json:"user_info"`
RDTrafficUsed uint64 `json:"rd_traffic_used"`
LibrarySize int `json:"library_size"` // Number of torrents in the library
RepairQueueStr string `json:"repair_queue"` // List of torrents in the repair queue
TorrentsToRepair string `json:"repair_queue"` // List of torrents in the repair queue
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
Sys uint64 `json:"sys"` // System memory in MB
@@ -61,17 +61,18 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
repairQueueStr := ""
if zr.torMgr.RepairQueue == nil {
repairQueueStr = "repair is disabled"
repairQueueStr = "uninitialized"
} else if zr.torMgr.RepairQueue.IsEmpty() {
repairQueueStr = "empty"
} else {
var repairList []string
for _, torrent := range zr.torMgr.RepairQueue.ToSlice() {
if torrent == nil {
repairQueueStr += " ⬅ 'all torrents'"
} else {
repairQueueStr += fmt.Sprintf(" ⬅ %s", zr.torMgr.GetKey(torrent))
if torrent != nil {
repairList = append(repairList, zr.torMgr.GetKey(torrent))
}
}
sort.Strings(repairList)
repairQueueStr = strings.Join(repairList, ", ")
}
sortedIDs := zr.torMgr.OnceDoneBin.ToSlice()
@@ -95,7 +96,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
UserInfo: userInfo,
RDTrafficUsed: bToGb(uint64(rdTrafficUsed)),
LibrarySize: allTorrents.Count(),
RepairQueueStr: repairQueueStr,
TorrentsToRepair: repairQueueStr,
MemAlloc: bToMb(mem.Alloc),
TotalAlloc: bToMb(mem.TotalAlloc),
Sys: bToMb(mem.Sys),
@@ -307,7 +308,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
<td colspan="2">%v</td>
</tr>
<tr>
<td>Repair Queue</td>
<td>Torrents to be repaired</td>
<td colspan="2">%s</td>
</tr>
<tr>
@@ -409,7 +410,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
response.Config.ShouldForceIPv6(),
response.Config.GetOnLibraryUpdate(),
response.IDsToDelete,
response.RepairQueueStr,
response.TorrentsToRepair,
response.Hosts,
)