Fix progress calculation to support both mbleft and mbmissing fields
- SABnzbd API uses different field names for remaining bytes - Test data uses mbmissing, but real API may use mbleft - Support both field names to handle all cases - Fixes DownloadBuilder test failures
This commit is contained in:
@@ -159,7 +159,9 @@ function matchSabSlots(slots, context) {
|
||||
if (showAll ? allTags.length > 0 : !!matchedUserTag) {
|
||||
// Calculate progress from SABnzbd slot data
|
||||
const mbValue = slot.mb !== undefined && slot.mb !== null ? parseFloat(slot.mb) : 0;
|
||||
const mbLeftValue = slot.mbleft !== undefined && slot.mbleft !== null ? parseFloat(slot.mbleft) : 0;
|
||||
const mbLeftValue = (slot.mbleft !== undefined && slot.mbleft !== null) || (slot.mbmissing !== undefined && slot.mbmissing !== null)
|
||||
? parseFloat(slot.mbleft || slot.mbmissing)
|
||||
: 0;
|
||||
const progress = mbValue > 0 ? ((mbValue - mbLeftValue) / mbValue) * 100 : 0;
|
||||
|
||||
const dlObj = {
|
||||
@@ -209,7 +211,9 @@ function matchSabSlots(slots, context) {
|
||||
if (showAll ? allTags.length > 0 : !!matchedUserTag) {
|
||||
// Calculate progress from SABnzbd slot data
|
||||
const mbValue = slot.mb !== undefined && slot.mb !== null ? parseFloat(slot.mb) : 0;
|
||||
const mbLeftValue = slot.mbleft !== undefined && slot.mbleft !== null ? parseFloat(slot.mbleft) : 0;
|
||||
const mbLeftValue = (slot.mbleft !== undefined && slot.mbleft !== null) || (slot.mbmissing !== undefined && slot.mbmissing !== null)
|
||||
? parseFloat(slot.mbleft || slot.mbmissing)
|
||||
: 0;
|
||||
const progress = mbValue > 0 ? ((mbValue - mbLeftValue) / mbValue) * 100 : 0;
|
||||
|
||||
const dlObj = {
|
||||
|
||||
Reference in New Issue
Block a user