Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only saves last playerUpdate when downloading data was successful #731

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export async function updateData(url: string, file = "./sample/data1.json") {
value2: "0",
});
}
connection.query(
"INSERT INTO data (value1, value2) VALUES(?, ?) ON DUPLICATE KEY UPDATE value2=?",
["playerUpdate" + league, currentTime, currentTime],
);
// Locks the database to prevent updates
connection.query("INSERT IGNORE INTO data (value1, value2) VALUES (?, ?)", [
"locked" + league,
Expand Down Expand Up @@ -100,6 +96,11 @@ export async function updateData(url: string, file = "./sample/data1.json") {
if (newTransfer == "FAILURE") {
return;
}
// Only updates the time for lastUpdate when getting the data was successful
connection.query(
"INSERT INTO data (value1, value2) VALUES(?, ?) ON DUPLICATE KEY UPDATE value2=?",
["playerUpdate" + league, currentTime, currentTime],
);
players.sort((a: players, b: players) => (a.club > b.club ? 1 : -1)); // Makes sure that the players are sorted by their club
// Updates countdown and the transfer market status
await connection.query(
Expand Down