mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 16:04:36 +00:00
store metadata in bigquery
This commit is contained in:
@@ -229,7 +229,7 @@
|
||||
* alert on unit captured or destroyed 12/20/2024
|
||||
* only check islands/clusters when being attacked DONE 12/10/2024
|
||||
* only calculate name if tile changes DONE 12/10/2024
|
||||
* store in BigQuery
|
||||
* store in BigQuery DONE 12/10/2024
|
||||
* allow longer names and allow them to be displayed in the Rank UI not be cut
|
||||
* make boats work on lakes (& oceania)
|
||||
* record game winner
|
||||
|
||||
@@ -53,6 +53,8 @@ export class LocalServer {
|
||||
console.log('local server ending game')
|
||||
clearInterval(this.endTurnIntervalID)
|
||||
const record = CreateGameRecord(this.gameID, this.gameConfig, this.turns, this.startedAt, Date.now())
|
||||
// Clear turns because beacon only supports up to 64kb
|
||||
record.turns = []
|
||||
// For unload events, sendBeacon is the only reliable method
|
||||
const blob = new Blob([JSON.stringify(GameRecordSchema.parse(record))], {
|
||||
type: 'application/json'
|
||||
|
||||
@@ -8,12 +8,6 @@ const bigquery = new BigQuery();
|
||||
|
||||
export async function archive(gameRecord: GameRecord) {
|
||||
try {
|
||||
console.log(`writing game ${gameRecord.id} to gcs`)
|
||||
const bucket = storage.bucket("openfront-games");
|
||||
const file = bucket.file(gameRecord.id);
|
||||
await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), {
|
||||
contentType: 'application/json'
|
||||
});
|
||||
// Save metadata to BigQuery
|
||||
const row = {
|
||||
id: gameRecord.id,
|
||||
@@ -34,7 +28,15 @@ export async function archive(gameRecord: GameRecord) {
|
||||
.insert([row]);
|
||||
|
||||
console.log(`wrote game metadata to BigQuery: ${gameRecord.id}`);
|
||||
if (gameRecord.turns.length > 0) {
|
||||
console.log(`writing game ${gameRecord.id} to gcs`)
|
||||
const bucket = storage.bucket("openfront-games");
|
||||
const file = bucket.file(gameRecord.id);
|
||||
await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), {
|
||||
contentType: 'application/json'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`error writing to gcs: ${error}`)
|
||||
console.log(`error archiving game record: ${error}`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user