-
Notifications
You must be signed in to change notification settings - Fork 304
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 #2685 from odota/readblob
make blobstore the primary
- Loading branch information
Showing
121 changed files
with
37,320 additions
and
4,876 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,5 @@ docker-compose.override.yml | |
STEAM_ACCOUNT_DATA*.txt | ||
.DS_Store | ||
.vscode | ||
build | ||
build | ||
.nyc_output |
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 @@ | ||
json |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:21-bullseye | ||
FROM node:20 | ||
|
||
ENV NPM_CONFIG_LOGLEVEL warn | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { archivePut } from '../store/archive.js'; | ||
import { | ||
getArchivedMatch, | ||
getMatchData, | ||
getPlayerMatchData, | ||
} from '../store/queries.js'; | ||
const { Archive } = await import('../store/archive.js'); | ||
const { tryReadArchivedMatch } = await import('../store/getArchivedData.js'); | ||
const { getMatchDataFromCassandra, getPlayerMatchData } = await import( | ||
'../store/queries.js' | ||
); | ||
|
||
// Read some match data | ||
const match = { | ||
...(await getMatchData('7465883253', 'cassandra')), | ||
players: await getPlayerMatchData('7465883253'), | ||
...(await getMatchDataFromCassandra(7465883253)), | ||
players: await getPlayerMatchData(7465883253), | ||
}; | ||
const blob = Buffer.from(JSON.stringify(match)); | ||
|
||
const archive = new Archive('match'); | ||
// Archive it | ||
const putRes = await archivePut(match.match_id?.toString() ?? '', blob); | ||
const putRes = await archive.archivePut(match.match_id?.toString() ?? '', blob); | ||
console.log(putRes); | ||
|
||
// Read it back | ||
const readBack = await getArchivedMatch(match.match_id?.toString() ?? ''); | ||
const readBack = await tryReadArchivedMatch(match.match_id?.toString() ?? ''); | ||
|
||
console.log(JSON.stringify(match).length, JSON.stringify(readBack).length); | ||
|
||
// Verify we get back null for invalid match id | ||
const nullMatch = await getArchivedMatch('123'); | ||
const nullMatch = await tryReadArchivedMatch('123'); | ||
console.log(nullMatch); | ||
|
||
// Confirm API returns the same data whether we used the archive or not |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import fs from 'fs'; | ||
import spec from '../routes/spec.js'; | ||
import spec from '../routes/spec'; | ||
|
||
fs.writeFileSync('./spec.json', JSON.stringify(spec, null, 2), 'utf-8'); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import fs from 'fs'; | ||
const { getPlayerMatchesWithMetadata } = await import( | ||
'../store/queries.js' | ||
); | ||
const { doArchivePlayerMatches } = await import('../store/getArchivedData.js'); | ||
|
||
// Write player blob to archive | ||
await doArchivePlayerMatches('88367253'); | ||
|
||
// Read it back | ||
// await getArchivedPlayerMatches('88367253'); | ||
|
||
// Check the combined getPlayerMatches results | ||
const readBack = await getPlayerMatchesWithMetadata('88367253', { | ||
project: [], | ||
projectAll: true, | ||
}); | ||
console.log(readBack[1]); | ||
|
||
// There shouldn't be any duplicate match IDs | ||
// The data should be the same | ||
fs.writeFileSync('./build/88367253,json', JSON.stringify(readBack[0], null, 2)); |
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 |
---|---|---|
@@ -1,27 +1,19 @@ | ||
// Issues reparse requests for all matches in postgres that aren't parsed | ||
import db from '../store/db'; | ||
import { insertMatchPromise } from '../store/queries'; | ||
import { getDataPromise, generateJob } from '../util/utility'; | ||
import queue from '../store/queue'; | ||
|
||
async function start() { | ||
const matches = await db.raw( | ||
'select match_id from matches where version IS NULL' | ||
'select match_id from matches where version IS NULL', | ||
); | ||
console.log(matches.rows.length); | ||
for (let i = 0; i < matches.rows.length; i++) { | ||
const input = matches.rows[i]; | ||
// match id request, get data from API | ||
const body: any = await getDataPromise( | ||
generateJob('api_details', input).url | ||
await queue.addReliableJob( | ||
{ name: 'parse', data: { match_id: input.match_id } }, | ||
{}, | ||
); | ||
// match details response | ||
const match = body.result; | ||
const job = await insertMatchPromise(match, { | ||
type: 'api', | ||
attempts: 1, | ||
priority: 1, | ||
forceParse: true, | ||
}); | ||
} | ||
} | ||
start(); |
Oops, something went wrong.