From 5538df2d7d571d5a382c4a79fa6be453f4fae6f0 Mon Sep 17 00:00:00 2001 From: zkldi Date: Thu, 17 Nov 2022 23:16:44 +0000 Subject: [PATCH] feat: run linter and fix pushing to wrong banch --- server/src/lib/database-seeds/repo.ts | 12 +++++++---- server/src/lib/jobs/update-sp12-data.ts | 27 +++++++++++++++---------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/server/src/lib/database-seeds/repo.ts b/server/src/lib/database-seeds/repo.ts index 3d50e5c95..3acbc5fbb 100644 --- a/server/src/lib/database-seeds/repo.ts +++ b/server/src/lib/database-seeds/repo.ts @@ -5,8 +5,8 @@ import { asyncExec } from "utils/misc"; import fs from "fs/promises"; import os from "os"; import path from "path"; +import type { ICollection } from "monk"; import type { Game } from "tachi-common"; -import { ICollection } from "monk"; const logger = CreateLogCtx(__filename); @@ -271,8 +271,12 @@ export async function PullDatabaseSeeds( } } -export async function BacksyncCollectionToBothBranches(collectionName: SeedsCollections, collection: ICollection, commitMessage: string) { - for (const branch of ["staging", "release/v2." + VERSION_INFO.minor]) { +export async function BacksyncCollectionToBothBranches( + collectionName: SeedsCollections, + collection: ICollection, + commitMessage: string +) { + for (const branch of ["staging", `release/2.${VERSION_INFO.minor}`]) { const repo = await PullDatabaseSeeds(null, branch); let charts = await collection.find({}); @@ -286,4 +290,4 @@ export async function BacksyncCollectionToBothBranches(collectionName: SeedsColl await repo.Destroy(); } -} \ No newline at end of file +} diff --git a/server/src/lib/jobs/update-sp12-data.ts b/server/src/lib/jobs/update-sp12-data.ts index 1e89fb6fe..8e6a758f7 100644 --- a/server/src/lib/jobs/update-sp12-data.ts +++ b/server/src/lib/jobs/update-sp12-data.ts @@ -2,15 +2,15 @@ /* eslint-disable no-case-declarations */ /* eslint-disable no-param-reassign */ import db from "external/mongo/db"; +import { BacksyncCollectionToBothBranches } from "lib/database-seeds/repo"; import CreateLogCtx from "lib/logger/logger"; import fetch from "node-fetch"; import p from "prudence"; +import { RecalcAllScores } from "utils/calculations/recalc-scores"; import { WrapScriptPromise } from "utils/misc"; import { FindChartWithPTDF } from "utils/queries/charts"; import { FindSongOnTitle } from "utils/queries/songs"; import type { ChartDocument, Difficulties, integer } from "tachi-common"; -import { RecalcAllScores } from "utils/calculations/recalc-scores"; -import { BacksyncCollectionToBothBranches } from "lib/database-seeds/repo"; const logger = CreateLogCtx(__filename); @@ -159,19 +159,20 @@ async function FetchSP12Data() { ? val.toFixed(2) : `12${stringVal.replace(/(個人差|地力)/u, "")}`; - const idvDiff =stringVal.includes("個人差"); + const idvDiff = stringVal.includes("個人差"); const existingTlInfo = chart.tierlistInfo[ktKey]; - if (existingTlInfo && - + if ( + existingTlInfo && existingTlInfo.text === text && existingTlInfo.value === val && - existingTlInfo.individualDifference === idvDiff) { - continue; - } + existingTlInfo.individualDifference === idvDiff + ) { + continue; + } - updatedChartIDs.push(chart.chartID); + updatedChartIDs.push(chart.chartID); await db.charts.iidx.update( { @@ -194,7 +195,7 @@ async function FetchSP12Data() { if (updatedChartIDs.length !== 0) { logger.info(`Finished applying SP12 changes. Recalcing.`); - logger.info("These changes will be backsynced by a separate script.") + logger.info("These changes will be backsynced by a separate script."); logger.info(`Recalcing scores.`); await RecalcAllScores({ @@ -204,7 +205,11 @@ async function FetchSP12Data() { logger.info(`Finished recalcing scores.`); - await BacksyncCollectionToBothBranches("charts-iidx", db.charts.iidx, "Update SP12 Tierlist"); + await BacksyncCollectionToBothBranches( + "charts-iidx", + db.charts.iidx, + "Update SP12 Tierlist" + ); } process.exit(0);