Skip to content

Commit

Permalink
Tweak BulkAdd logging
Browse files Browse the repository at this point in the history
Fix "added X markers" logging, and don't log for a dry run.
  • Loading branch information
danrahn committed Oct 21, 2023
1 parent 8d73c05 commit d070f5f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Server/Commands/CoreCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,11 @@ class CoreCommands {

const currentMarkers = await PlexQueries.getMarkersAuto(metadataId);
const addResult = await PlexQueries.bulkAddSimple(currentMarkers, metadataId, start, end, markerType, resolveType, ignored);
await CoreCommands.#bulkAddPostProcess(addResult, currentMarkers.markers);
const adds = await CoreCommands.#bulkAddPostProcess(addResult, currentMarkers.markers);

Log.info(`Added ${addResult.applied} markers to item ${metadataId} (explicitly ignored ${ignored.length})`);
if (resolveType !== BulkMarkerResolveType.DryRun) {
Log.info(`Added ${adds} markers to item ${metadataId} (explicitly ignored ${ignored.length})`);
}

return addResult;
}
Expand All @@ -377,10 +379,13 @@ class CoreCommands {

const currentMarkers = await PlexQueries.getMarkersAuto(metadataId);
const addResult = await PlexQueries.bulkAddCustom(currentMarkers, metadataId, markerType, resolveType, newMarkers);
await CoreCommands.#bulkAddPostProcess(addResult, currentMarkers.markers);
const adds = await CoreCommands.#bulkAddPostProcess(addResult, currentMarkers.markers);

if (resolveType !== BulkMarkerResolveType.DryRun) {
const ignored = addResult.ignoredEpisodes?.length || 0;
Log.info(`Added ${adds} markers to item ${metadataId} (explicitly or implicitly ignored ${ignored})`);
}

const ignored = addResult.ignoredEpisodes?.length || 0;
Log.info(`Added ${addResult.applied} markers to item ${metadataId} (explicitly or implicitly ignored ${ignored})`);
return addResult;
}

Expand All @@ -390,7 +395,7 @@ class CoreCommands {
static async #bulkAddPostProcess(addResult, previousMarkers) {
if (!addResult.applied) {
// Nothing applied, nothing to do.
return;
return 0;
}

const episodes = Object.values(addResult.episodeMap);
Expand Down Expand Up @@ -445,6 +450,7 @@ class CoreCommands {
await BackupManager.recordAdds(adds);
await BackupManager.recordEdits(edits, oldMarkerTimings);
await BackupManager.recordDeletes(deletes);
return adds.length;
}

/**
Expand Down

0 comments on commit d070f5f

Please sign in to comment.