Skip to content

Commit

Permalink
improved searching speed & slow system detection logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkih committed Apr 3, 2022
1 parent 243314a commit 1093c0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -42,7 +42,7 @@ let pendingBookingPromise = undefined;
`Valid locations ${validLocations.map(({ name }) => name).join(", ")}`
);

tracker.init();
tracker.init((config.throttle * 1000) / config.sessions);

const numOfSessions = Math.min(config.sessions ?? 1, 6);
const startDate = getStartDateOfCurrentWeek();
Expand Down
7 changes: 3 additions & 4 deletions src/tracker.js
@@ -1,19 +1,18 @@
const logger = require("./logger");

const INTERVAL = 15;
const MIN_INTERVAL = 30 * 1000;

const tracker = {
checks: 0,
start: undefined,
lastChecks: undefined,
slow: false,
init() {
init(interval) {
setInterval(() => {
if (this.checks === 0 || typeof this.start === "undefined") {
return;
}

this.lastChecks = this.checks;
if (this.lastChecks === this.checks) {
if (!this.slow) {
logger.warn("Booking system is running slow...");
Expand All @@ -30,7 +29,7 @@ const tracker = {
logger.info(`CHECKING ${num} WEEKS / SECOND`);
this.lastChecks = this.checks;
this.slow = false;
}, INTERVAL * 1500);
}, Math.max(interval * 15, MIN_INTERVAL));
},
track() {
if (this.checks === 0) {
Expand Down

0 comments on commit 1093c0f

Please sign in to comment.