Skip to content

Commit

Permalink
Attempt to fix bug that causes matchday to be ended twice (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasdotcom authored Sep 25, 2023
1 parent 6a2b7ea commit ab12511
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions scripts/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,50 +278,34 @@ async function update() {
const time = countdown[0].value2;
// Updates the countdown
if (transferOpen) {
if (time - 11 > 0) {
if (time - 10 > 0) {
connection3.query("UPDATE data SET value2=? WHERE value1=?", [
time - 10,
"countdown" + e.name,
]);
} else {
// Makes sure that the amount of time left in the transfer is not unknown
if (time > 0) {
console.log(
`Predicting start of matchday in ${time} seconds for ${e.name}`,
);
// Makes sure to wait until the time is done
setTimeout(
() => {
updateData(e.url);
},
time * 1000 + 1,
);
updateData(e.url);
connection3.query("UPDATE data SET value2=? WHERE value1=?", [
time - 10,
0,
"countdown" + e.name,
]);
}
}
} else {
if (time - 11 > 0) {
if (time - 10 > 0) {
connection3.query("UPDATE data SET value2=? WHERE value1=?", [
time - 10,
"countdown" + e.name,
]);
} else {
// Makes sure that the amount of time left in the matchday is not unknown
if (time > 0) {
console.log(
`Predicting end of matchday in ${time} seconds for ${e.name}`,
);
setTimeout(
() => {
updateData(e.url);
},
time * 1000 + 1,
);
updateData(e.url);
connection3.query("UPDATE data SET value2=? WHERE value1=?", [
time - 10,
0,
"countdown" + e.name,
]);
}
Expand Down

0 comments on commit ab12511

Please sign in to comment.