Finished optimizing automated queue transactions.
This commit is contained in:
parent
dd36b1d923
commit
75301ec7d9
|
|
@ -360,7 +360,6 @@ class queue{
|
||||||
chanDB.media.liveRemainder = this.nowPlaying.uuid;
|
chanDB.media.liveRemainder = this.nowPlaying.uuid;
|
||||||
|
|
||||||
//Save the chanDB
|
//Save the chanDB
|
||||||
console.log("Saving db from goLive() :363");
|
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -593,12 +592,12 @@ class queue{
|
||||||
//For each item
|
//For each item
|
||||||
for(let item of foundItems){
|
for(let item of foundItems){
|
||||||
//Remove media, passing down chanDB so we're not looking again and again
|
//Remove media, passing down chanDB so we're not looking again and again
|
||||||
await this.removeMedia(item.uuid, socket, chanDB, true);
|
await this.removeMedia(item.uuid, socket, chanDB, true, true);
|
||||||
|
|
||||||
//If this is the current item
|
//If this is the current item
|
||||||
if(this.nowPlaying != null && item.uuid == this.nowPlaying.uuid){
|
if(this.nowPlaying != null && item.uuid == this.nowPlaying.uuid){
|
||||||
//End it
|
//End it
|
||||||
await this.end(false, true, false, chanDB);
|
await this.end(false, true, false, chanDB, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -609,7 +608,8 @@ class queue{
|
||||||
//Refresh next timer
|
//Refresh next timer
|
||||||
await this.refreshNextTimer();
|
await this.refreshNextTimer();
|
||||||
|
|
||||||
console.log("Saved by removeRange() :599");
|
//Broadcast Queue
|
||||||
|
await this.broadcastQueue(chanDB);
|
||||||
|
|
||||||
}catch(err){
|
}catch(err){
|
||||||
//If this was originated by someone
|
//If this was originated by someone
|
||||||
|
|
@ -749,9 +749,10 @@ class queue{
|
||||||
* @param {Socket} socket - Requesting Socket
|
* @param {Socket} socket - Requesting Socket
|
||||||
* @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access
|
* @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access
|
||||||
* @param {Boolean} noScheduling - Disables schedule timer refresh and this.save() calls if true, good for internal function calls
|
* @param {Boolean} noScheduling - Disables schedule timer refresh and this.save() calls if true, good for internal function calls
|
||||||
|
* @param {Boolean} noBroadcast - Disables schedule broadcasting to clients, good for internal function calls
|
||||||
* @returns {Media} Deleted Media Item
|
* @returns {Media} Deleted Media Item
|
||||||
*/
|
*/
|
||||||
async removeMedia(uuid, socket, chanDB, noScheduling = false){
|
async removeMedia(uuid, socket, chanDB, noScheduling = false, noBroadcast = false){
|
||||||
//If we're streamlocked
|
//If we're streamlocked
|
||||||
if(this.streamLock){
|
if(this.streamLock){
|
||||||
//If an originating socket was provided for this request
|
//If an originating socket was provided for this request
|
||||||
|
|
@ -798,13 +799,15 @@ class queue{
|
||||||
}
|
}
|
||||||
//Otherwise
|
//Otherwise
|
||||||
}else{
|
}else{
|
||||||
//Broadcast changes
|
//If broadcasting is enabled
|
||||||
this.broadcastQueue(chanDB);
|
if(!noBroadcast){
|
||||||
|
//Broadcast changes
|
||||||
|
this.broadcastQueue(chanDB);
|
||||||
|
}
|
||||||
|
|
||||||
//If saving is disabled
|
//If saving is disabled
|
||||||
if(!noScheduling){
|
if(!noScheduling){
|
||||||
//Save changes to the DB
|
//Save changes to the DB
|
||||||
console.log("Saving db from removeMedia() :792");
|
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -861,16 +864,21 @@ class queue{
|
||||||
|
|
||||||
//If saving is enabled (seperate from all DB transactions since caller function may want modifications but handle saving on its own)
|
//If saving is enabled (seperate from all DB transactions since caller function may want modifications but handle saving on its own)
|
||||||
if(!noScheduling){
|
if(!noScheduling){
|
||||||
console.log("Saving db from removeMedia() :849");
|
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Broadcast the channel
|
//If broadcasting is enabled
|
||||||
this.broadcastQueue(chanDB);
|
if(!noBroadcast){
|
||||||
|
//Broadcast the channel
|
||||||
|
this.broadcastQueue(chanDB);
|
||||||
|
}
|
||||||
|
|
||||||
}catch(err){
|
}catch(err){
|
||||||
//Broadcast the channel
|
//If broadcasting is enabled
|
||||||
this.broadcastQueue();
|
if(!noBroadcast){
|
||||||
|
//Broadcast the channel
|
||||||
|
this.broadcastQueue();
|
||||||
|
}
|
||||||
|
|
||||||
//If this was originated by someone
|
//If this was originated by someone
|
||||||
if(socket != null){
|
if(socket != null){
|
||||||
|
|
@ -1052,7 +1060,6 @@ class queue{
|
||||||
try{
|
try{
|
||||||
//If saving is enabled (seperate from all DB transactions since caller function may want modifications but handle saving on its own)
|
//If saving is enabled (seperate from all DB transactions since caller function may want modifications but handle saving on its own)
|
||||||
if(!noSave){
|
if(!noSave){
|
||||||
console.log("Saving db from scheduleMedia() :1040");
|
|
||||||
//Save the database
|
//Save the database
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
}
|
}
|
||||||
|
|
@ -1149,9 +1156,6 @@ class queue{
|
||||||
return record.uuid != mediaObj.uuid;
|
return record.uuid != mediaObj.uuid;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
console.log("Saving db from start() :1138");
|
|
||||||
|
|
||||||
//Save the channel
|
//Save the channel
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
|
|
||||||
|
|
@ -1286,9 +1290,6 @@ class queue{
|
||||||
//broadcast queue using unsaved archive, run this before chanDB.save() for better responsiveness
|
//broadcast queue using unsaved archive, run this before chanDB.save() for better responsiveness
|
||||||
this.broadcastQueue(chanDB);
|
this.broadcastQueue(chanDB);
|
||||||
|
|
||||||
|
|
||||||
console.log("Saving db from end() :1275");
|
|
||||||
|
|
||||||
//Save our changes to the DB
|
//Save our changes to the DB
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
}
|
}
|
||||||
|
|
@ -1318,7 +1319,6 @@ class queue{
|
||||||
}
|
}
|
||||||
//Disable stream lock
|
//Disable stream lock
|
||||||
this.streamLock = false;
|
this.streamLock = false;
|
||||||
console.log("testem");
|
|
||||||
|
|
||||||
//We don't have to save here since someone else will do it for us :)
|
//We don't have to save here since someone else will do it for us :)
|
||||||
//Reminder for those of us reading this in the future since I'm a dipshit: this only clears the DB liveRemainder, NOT the RAM backed variable
|
//Reminder for those of us reading this in the future since I'm a dipshit: this only clears the DB liveRemainder, NOT the RAM backed variable
|
||||||
|
|
@ -1385,9 +1385,6 @@ class queue{
|
||||||
//Throw the livestream into the archive
|
//Throw the livestream into the archive
|
||||||
chanDB.media.archived.push(wasPlaying);
|
chanDB.media.archived.push(wasPlaying);
|
||||||
|
|
||||||
|
|
||||||
console.log("Saving db from livestreamOverwriteSchedule() :1373");
|
|
||||||
|
|
||||||
//Save the DB
|
//Save the DB
|
||||||
await chanDB.save();
|
await chanDB.save();
|
||||||
|
|
||||||
|
|
@ -1509,7 +1506,7 @@ class queue{
|
||||||
const mediaObj = entry[1];
|
const mediaObj = entry[1];
|
||||||
|
|
||||||
//Remove media from queue without calling chanDB.save() to make room before we move everything
|
//Remove media from queue without calling chanDB.save() to make room before we move everything
|
||||||
await this.removeMedia(mediaObj.uuid, null, chanDB, true);
|
await this.removeMedia(mediaObj.uuid, null, chanDB, true, true);
|
||||||
|
|
||||||
mediaObj.genUUID();
|
mediaObj.genUUID();
|
||||||
|
|
||||||
|
|
@ -1525,6 +1522,9 @@ class queue{
|
||||||
|
|
||||||
//Schedule the moved schedule, letting scheduleMedia save our changes for us, starting w/o saves to prevent over-saving
|
//Schedule the moved schedule, letting scheduleMedia save our changes for us, starting w/o saves to prevent over-saving
|
||||||
await this.scheduleMedia(newSched, null, chanDB);
|
await this.scheduleMedia(newSched, null, chanDB);
|
||||||
|
|
||||||
|
//Broadcast the queue now that everything is hunky dory
|
||||||
|
await this.broadcastQueue(chanDB);
|
||||||
}catch(err){
|
}catch(err){
|
||||||
//Null out live remainder for the next stream
|
//Null out live remainder for the next stream
|
||||||
this.liveRemainder = null;
|
this.liveRemainder = null;
|
||||||
|
|
@ -1881,9 +1881,6 @@ class queue{
|
||||||
//Update schedule to only contain what hasn't been played yet
|
//Update schedule to only contain what hasn't been played yet
|
||||||
chanDB.media.scheduled = newSched;
|
chanDB.media.scheduled = newSched;
|
||||||
|
|
||||||
|
|
||||||
console.log("Saving db from rehydrateQueue() :1869");
|
|
||||||
|
|
||||||
//Save the DB
|
//Save the DB
|
||||||
await chanDB.save()
|
await chanDB.save()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue