Skip to content

Commit

Permalink
skip refreshing data when game is updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Jul 4, 2024
1 parent 0fd8ace commit 73a1847
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tarkov-data-manager/jobs/check-scanners.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CheckScansJob extends DataJob {
]);

for (const service of services) {
if (!service.name === 'Trading') continue;
if (service.name !== 'Trading') continue;
if (service.status === 1) {
this.logger.log('Game is updating, skipping scanner check')
return;
Expand Down
13 changes: 13 additions & 0 deletions src/tarkov-data-manager/jobs/update-td-data.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import DataJob from '../modules/data-job.mjs';
import tarkovDevData from '../modules/tarkov-dev-data.mjs';
import webSocketServer from '../modules/websocket-server.mjs';

class UpdateTdDataJob extends DataJob {
constructor(options) {
super({...options, name: 'update-td-data'});
}

async run() {
const services = await tarkovDevData.status().then(status => status.services).catch(error => {
this.logger.error(`Error getting EFT services status: ${error.message}`);
return [];
});

const tradingService = services.find(s => s.name === 'Trading');
if (tradingService?.status === 1 && webSocketServer.launchedScanners().length === 0) {
this.logger.log('Game is updating, skipping data update');
return;

}

this.logger.log('Downloading data from...');
this.logger.time('td-download');
const results = await tarkovDevData.downloadAll('regular');
Expand Down

0 comments on commit 73a1847

Please sign in to comment.