From 7f03e7d5c987c8a7831ea49dbb03307a01410337 Mon Sep 17 00:00:00 2001 From: CyferShepard Date: Tue, 8 Jul 2025 22:48:08 +0200 Subject: [PATCH] fix for #417, sets duration to 0 if negative int detected --- .../jf_playback_reporting_plugin_data.js | 65 ++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/backend/models/jf_playback_reporting_plugin_data.js b/backend/models/jf_playback_reporting_plugin_data.js index f00277c..ad36efb 100644 --- a/backend/models/jf_playback_reporting_plugin_data.js +++ b/backend/models/jf_playback_reporting_plugin_data.js @@ -1,32 +1,39 @@ - ////////////////////////// pn delete move to playback - const columnsPlaybackReporting = [ - "rowid", - "DateCreated", - "UserId", - "ItemId", - "ItemType", - "ItemName", - "PlaybackMethod", - "ClientName", - "DeviceName", - "PlayDuration", - ]; +////////////////////////// pn delete move to playback +const columnsPlaybackReporting = [ + "rowid", + "DateCreated", + "UserId", + "ItemId", + "ItemType", + "ItemName", + "PlaybackMethod", + "ClientName", + "DeviceName", + "PlayDuration", +]; +const mappingPlaybackReporting = (item) => { + let duration = item[9]; - const mappingPlaybackReporting = (item) => ({ - rowid:item[0] , - DateCreated:item[1] , - UserId:item[2] , - ItemId:item[3] , - ItemType:item[4] , - ItemName:item[5] , - PlaybackMethod:item[6] , - ClientName:item[7] , - DeviceName:item[8] , - PlayDuration:item[9] , - }); + if (duration === null || duration === undefined || duration < 0) { + duration = 0; + } - module.exports = { - columnsPlaybackReporting, - mappingPlaybackReporting, - }; \ No newline at end of file + return { + rowid: item[0], + DateCreated: item[1], + UserId: item[2], + ItemId: item[3], + ItemType: item[4], + ItemName: item[5], + PlaybackMethod: item[6], + ClientName: item[7], + DeviceName: item[8], + PlayDuration: duration, + }; +}; + +module.exports = { + columnsPlaybackReporting, + mappingPlaybackReporting, +};