-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logic to prefer archive for parsed matches
- Loading branch information
1 parent
213ba64
commit 6ebb27d
Showing
4 changed files
with
66 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import { archivePut, archiveGet } from '../store/archive.js'; | ||
import { getMatchData, getPlayerMatchData } from '../store/queries.js'; | ||
import { archivePut } from '../store/archive.js'; | ||
import { getArchivedMatch, getMatchData, getPlayerMatchData } from '../store/queries.js'; | ||
|
||
// Read some match data | ||
const match = await getMatchData(7465883253); | ||
const players = await getPlayerMatchData(7465883253); | ||
const blob = Buffer.from(JSON.stringify({ ...match, players })); | ||
const match = {...await getMatchData(7465883253), players: await getPlayerMatchData(7465883253)}; | ||
const blob = Buffer.from(JSON.stringify(match)); | ||
|
||
// Archive it | ||
await archivePut(match.match_id.toString(), blob); | ||
const putRes = await archivePut(match.match_id.toString(), blob); | ||
console.log(putRes); | ||
|
||
// Read it back | ||
const readBack = await archiveGet(match.match_id.toString()); | ||
const readBack = await getArchivedMatch(match.match_id.toString()); | ||
|
||
console.log(blob.length, readBack.length); | ||
console.log(JSON.stringify(match).length, JSON.stringify(readBack).length); | ||
|
||
// Verify we get back null for invalid match id | ||
const nullMatch = await getArchivedMatch(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
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