chore(env): rename test environment to staging

This commit is contained in:
dahyeon committed 2026-06-07 01:01:13 -07:00
1 parent d0d578b2b0
commit eadae789c8
17 files changed
+160 -107

No files matched your search

+32 -15
View File
@@ -19,7 +19,7 @@
* -> join nickname base with RiotAccount.gameName
* -> verify/fetch puuid from Riot Account API
* -> fetch summoner / league / mastery / recent match ids from Riot API
* -> upsert lolympus-test.user
* -> upsert lolympus-staging.user
*/
"use strict";
@@ -32,7 +32,7 @@ const CONFIG = {
RIOT_API_KEY: process.env.RIOT_API_KEY ?? "",
DAKAO_DB_NAME: "dakao",
LOLYMPUS_DB_NAME: "lolympus-test",
LOLYMPUS_DB_NAME: "lolympus-staging",
RIOT_ACCOUNT_DB_NAME: process.env.RIOT_ACCOUNT_DB_NAME ?? "dakao",
RIOT_ACCOUNT_COLLECTION_NAME:
process.env.RIOT_ACCOUNT_COLLECTION_NAME ?? "RiotAccount",
@@ -50,7 +50,7 @@ const CONFIG = {
RECENT_MATCH_COUNT: Number(process.env.RECENT_MATCH_COUNT ?? 20),
FETCH_RECENT_MATCH_IDS: process.env.FETCH_RECENT_MATCH_IDS !== "false",
// Safe default. Set DRY_RUN=false to write into lolympus-test.user.
// Safe default. Set DRY_RUN=false to write into lolympus-staging.user.
DRY_RUN: process.env.DRY_RUN !== "false",
SAVE_DRY_RUN_RESULT: process.env.SAVE_DRY_RUN_RESULT !== "false",
OUTPUT_ONLY_RIOT_MATCHED: process.env.OUTPUT_ONLY_RIOT_MATCHED !== "false",
@@ -163,10 +163,10 @@ function maskConfigForStorage() {
function isRiotMatchedCandidate(candidate) {
return Boolean(
candidate.matchedRiotAccount &&
candidate.ambiguousRiotAccounts?.length === 0 &&
candidate.riotApiResult &&
!candidate.riotApiError &&
!candidate.riotEnrichmentError,
candidate.ambiguousRiotAccounts?.length === 0 &&
candidate.riotApiResult &&
!candidate.riotApiError &&
!candidate.riotEnrichmentError,
);
}
@@ -214,7 +214,10 @@ function remember(map, kakaoTalkId, patch) {
const nickname =
normalizeString(patch.kakaoTalkNickname) ||
normalizeString(current.kakaoTalkNickname);
const sources = new Set([...(current.sources ?? []), ...(patch.sources ?? [])]);
const sources = new Set([
...(current.sources ?? []),
...(patch.sources ?? []),
]);
const lastSeenCandidates = [current.lastSeenAt, patch.lastSeenAt]
.filter(Boolean)
.map((value) => new Date(value));
@@ -229,7 +232,9 @@ function remember(map, kakaoTalkId, patch) {
sources: [...sources],
lastSeenAt:
lastSeenCandidates.length > 0
? new Date(Math.max(...lastSeenCandidates.map((date) => date.getTime())))
? new Date(
Math.max(...lastSeenCandidates.map((date) => date.getTime())),
)
: null,
recentMessageCount:
(current.recentMessageCount ?? 0) + (patch.recentMessageCount ?? 0),
@@ -361,7 +366,12 @@ function pickRiotAccountForCandidate(candidate, index) {
const nicknameBase = candidate.nicknameBase;
if (!nicknameBase) {
return { source: "no-nickname-base", account: null, override, ambiguous: [] };
return {
source: "no-nickname-base",
account: null,
override,
ambiguous: [],
};
}
const exactMatches = index.exact.get(normalizeJoinKey(nicknameBase)) ?? [];
@@ -422,7 +432,9 @@ async function fetchRiotJson({ host, path, query }) {
});
if (response.status === 429) {
const retryAfterSeconds = Number(response.headers.get("retry-after") ?? 1);
const retryAfterSeconds = Number(
response.headers.get("retry-after") ?? 1,
);
await sleep(Math.max(1, retryAfterSeconds) * 1000);
continue;
}
@@ -431,7 +443,9 @@ async function fetchRiotJson({ host, path, query }) {
if (!response.ok) {
const body = await response.text().catch(() => "");
throw new Error(`Riot API failed ${response.status} ${url.pathname}: ${body}`);
throw new Error(
`Riot API failed ${response.status} ${url.pathname}: ${body}`,
);
}
return response.json();
@@ -670,11 +684,14 @@ async function enrichCandidatesWithRiot({ candidates, riotAccountIndex }) {
riotApiError,
riotEnrichment,
riotEnrichmentError,
preferredPositions: normalizePositions(match.override?.preferredPositions),
preferredPositions: normalizePositions(
match.override?.preferredPositions,
),
role: match.override?.role ?? "member",
isActivated: match.override?.isActivated ?? true,
targetKakaoTalkNickname:
normalizeString(match.override?.nickname) || candidate.kakaoTalkNickname,
normalizeString(match.override?.nickname) ||
candidate.kakaoTalkNickname,
});
}
@@ -798,7 +815,7 @@ async function upsertUsers({ lolympusDb, candidates }) {
preferredPositions:
candidate.preferredPositions?.length > 0
? candidate.preferredPositions
: existing?.preferredPositions ?? [],
: (existing?.preferredPositions ?? []),
isActivated: candidate.isActivated ?? true,
updatedAt: now,
};