free seat tracker rewrite

This commit is contained in:
2023-09-30 13:44:07 +02:00
parent fa5be769e2
commit 9e9c4b0ec6
4 changed files with 164 additions and 94 deletions

View File

@@ -209,28 +209,3 @@ module.exports.saveSettings = ( settings ) => {
}
fs.writeFileSync( path.join( __dirname + '/../../config/settings.config.json' ), settingsToSave );
};
const gc = () => {
// this function acts as the database garbage collector. TicketTimeout can be changed from the GUI.
this.getData( 'temp' ).then( tempData => {
let data = tempData;
console.info( '[ DB ] Garbage Collecting' );
for ( let item in data ) {
if ( new Date( data[ item ][ 'timestamp' ] ).getTime() + ( parseInt( settings.ticketTimeout ) * 1000 ) > new Date().getTime() ) {
delete data[ item ];
console.debug( '[ DB ] Garbage collected a session' );
}
}
} );
};
/*
Here, GC-Duty is scheduled to run every so often (defined in settings.config.json file, no GUI setting available.
If you are a developer and are thinking about adding a GUI setting for this, please consider that this is a
advanced setting and many people might not understand what it changes. The config file is mentioned in the
"advanced settings" section of the admin panel documentation where all the available settings in the config file
are explained in some detail.)
*/
setInterval( () => {
gc();
}, parseInt( settings.gcInterval ) * 1000 );