Skip to content

Commit

Permalink
Update getApiData.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung authored Nov 19, 2024
1 parent 75a5164 commit 5b1bf98
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions store/getApiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { insertMatch } from './insert';
import { getPGroup, type ApiMatch } from './pgroup';
import redis from './redis';

const blobArchive = new Archive('blob');
const blobArchive = config.ENABLE_BLOB_ARCHIVE ? new Archive('blob') : null;
/**
* Return API data by reading it without fetching.
* @param matchId
Expand All @@ -20,7 +20,7 @@ export async function readApiData(matchId: number): Promise<ApiMatch | null> {
);
const row = result.rows[0];
let data = row?.api ? (JSON.parse(row.api) as ApiMatch) : undefined;
if (!data && config.ENABLE_BLOB_ARCHIVE) {
if (!data && blobArchive) {
const archive = await blobArchive.archiveGet(`${matchId}_api`);
data = archive ? JSON.parse(archive.toString()) as ApiMatch : undefined;
}
Expand Down

0 comments on commit 5b1bf98

Please sign in to comment.