Major Backend SI Update part 2: added controllers
This commit is contained in:
1 parent
a51e207707
commit
dbb00fdb61
38 files changed
+2129
-1231
No files matched your search
@@ -20,11 +20,14 @@ const { logToFile } = require("./logService.js");
|
||||
const collectionManager = require('./collectionManager.js');
|
||||
const entryService = require("./entryService");
|
||||
const mediaManager = require("./mediaManager.js");
|
||||
const EntryNetwork = require("../models/EntryNetwork.js");
|
||||
const networkService = require("./networkService.js");
|
||||
const Network = require("../models/Network.js");
|
||||
|
||||
const _collectionManager = collectionManager;
|
||||
const _entryService = entryService;
|
||||
const _mediaManager = mediaManager;
|
||||
|
||||
const _networkService = networkService;
|
||||
class EntryManager {
|
||||
|
||||
constructor() {
|
||||
@@ -128,6 +131,25 @@ class EntryManager {
|
||||
})
|
||||
});
|
||||
|
||||
// * networks
|
||||
if (entryData.networks) {
|
||||
const oldNetworksIds = oldEntry.networks.map(network => network.id);
|
||||
for (const networkData of entryData.networks) {
|
||||
// If the entry already has this network, skip it
|
||||
if (oldNetworksIds.includes(networkData.id)) continue;
|
||||
|
||||
// Create or update the network
|
||||
const [oldNetwork, newNetwork] = await _networkService.createOrUpdateNetwork(networkData);
|
||||
let network = oldNetwork || newNetwork;
|
||||
if (!network) {
|
||||
throw new NotFoundError("Network not found");
|
||||
}
|
||||
|
||||
// Associate the new network with the entry
|
||||
await oldEntry.addNetwork(network);
|
||||
}
|
||||
}
|
||||
|
||||
// * For TV-Series (Seasons & Episodes)
|
||||
if (oldEntry.is_tvseries) {
|
||||
// ? Only refrech if the series's status is not 'Ended'
|
||||
|
||||
Reference in new issue
Block a user