Bug fixes

This commit is contained in:
Ben Adrian Sarmiento
2024-06-28 20:18:30 +02:00
parent f8f31b3b67
commit 7cd8c9e5c9
4 changed files with 25 additions and 8 deletions

View File

@@ -30,7 +30,7 @@ type RootResponse struct {
Infuse string `json:"infuse"`
Logs string `json:"logs"`
UserInfo *realdebrid.User `json:"user_info"`
APITrafficMB uint64 `json:"traffic_from_api"`
APITraffic uint64 `json:"traffic_from_api"`
RequestedMB uint64 `json:"requested_mb"`
ServedMB uint64 `json:"served_mb"`
LibrarySize int `json:"library_size"` // Number of torrents in the library
@@ -102,7 +102,7 @@ func (zr *Handlers) generateResponse(resp http.ResponseWriter, req *http.Request
Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
Logs: fmt.Sprintf("//%s/logs/", req.Host),
UserInfo: userInfo,
APITrafficMB: bToMb(uint64(trafficFromAPI)),
APITraffic: uint64(trafficFromAPI),
RequestedMB: bToMb(zr.downloader.RequestedBytes.Load()),
ServedMB: bToMb(zr.downloader.TotalBytes.Load()),
LibrarySize: allTorrents.Count(),
@@ -199,10 +199,10 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
}
efficiency := response.ServedMB * 100 / denominator
if zr.trafficOnStartup.Load() > response.APITrafficMB {
if zr.trafficOnStartup.Load() > response.APITraffic {
// it cannot be bigger than traffic logged
// so it must be a reset back to 0
zr.trafficOnStartup.Store(response.APITrafficMB * 1024 * 1024)
zr.trafficOnStartup.Store(0)
}
out += fmt.Sprintf(`
@@ -252,8 +252,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
response.Sys,
response.NumGC,
response.PID,
response.APITrafficMB,
response.APITrafficMB-bToMb(zr.trafficOnStartup.Load()),
bToMb(response.APITraffic),
bToMb(response.APITraffic-zr.trafficOnStartup.Load()),
response.RequestedMB,
response.ServedMB,
efficiency,