-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from ekzhang/develop
Release 3.0.7
- Loading branch information
Showing
5 changed files
with
52 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import assert from "assert"; | ||
import admin from "firebase-admin"; | ||
|
||
/** Fix games that have `endedAt === 0` due to a site migration bug in v3.0.0. */ | ||
export async function fixGames() { | ||
const badGames = await admin | ||
.database() | ||
.ref("games") | ||
.orderByChild("endedAt") | ||
.equalTo(0) | ||
.once("value"); | ||
|
||
for (const [gameId, game] of Object.entries(badGames.val())) { | ||
console.log(`Fixing game ${gameId}...`); | ||
console.log({ [gameId]: game }); | ||
assert.strictEqual(game.status, "done"); | ||
const events = await admin | ||
.database() | ||
.ref(`gameData/${gameId}/events`) | ||
.once("value"); | ||
let lastTime = 0; | ||
events.forEach((event) => { | ||
lastTime = event.val().time; | ||
}); | ||
console.log(`Setting endedAt = ${lastTime}...`); | ||
await admin.database().ref(`games/${gameId}/endedAt`).set(lastTime); | ||
console.log("Done.\n"); | ||
} | ||
|
||
console.log("Completed all games!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters