feat: enforce branches with seeds (#1064)

This commit is contained in:
zkldi
2024-05-08 20:03:42 +01:00
committed by GitHub
parent 4a80b1f516
commit 8167fb3fc5
3 changed files with 14 additions and 11 deletions
+7 -9
View File
@@ -310,18 +310,16 @@ export async function BacksyncCollection(
collection: ICollection,
commitMessage: string
) {
for (const branch of ["main"]) {
const repo = await PullDatabaseSeeds(undefined, branch);
const repo = await PullDatabaseSeeds(undefined);
let charts = await collection.find({});
let charts = await collection.find({});
await repo.WriteCollection(collectionName, charts);
await repo.WriteCollection(collectionName, charts);
// @ts-expect-error Force node to free the memory.
charts = null;
// @ts-expect-error Force node to free the memory.
charts = null;
await repo.CommitChangesBack(`${commitMessage} ${new Date().toISOString()}`);
await repo.CommitChangesBack(`${commitMessage} ${new Date().toISOString()}`);
await repo.Destroy();
}
await repo.Destroy();
}
+2
View File
@@ -88,6 +88,7 @@ export interface TachiServerConfig {
REPO_URL: string;
USER_NAME: string | null;
USER_EMAIL: string | null;
BRANCH?: string;
};
EMAIL_CONFIG?: {
FROM: string;
@@ -231,6 +232,7 @@ const err = p(config, {
REPO_URL: "string",
USER_NAME: "?string",
USER_EMAIL: "?string",
BRANCH: "*string",
}),
});
+5 -2
View File
@@ -7,7 +7,7 @@ import fjsh from "fast-json-stable-hash";
import { PullDatabaseSeeds } from "lib/database-seeds/repo";
import CreateLogCtx from "lib/logger/logger";
import UpdateIsPrimaryStatus from "lib/score-mutation/update-isprimary";
import { TachiConfig } from "lib/setup/config";
import { ServerConfig, TachiConfig } from "lib/setup/config";
import { RemoveStaleFolderShowcaseStats } from "lib/showcase/showcase";
import { UpdateQuestSubscriptions } from "lib/targets/quests";
import { RecalcAllScores } from "utils/calculations/recalc-scores";
@@ -357,7 +357,10 @@ async function SynchroniseDBWithSeeds() {
// Wait for mongo to connect first.
await monkDB.then(() => void 0);
const databaseSeedsRepo = await PullDatabaseSeeds(options.localPath);
const databaseSeedsRepo = await PullDatabaseSeeds(
options.localPath,
ServerConfig.SEEDS_CONFIG?.BRANCH
);
for await (const { collectionName, data } of databaseSeedsRepo.IterateCollections()) {
const spawnLogger = CreateLogCtx(`${collectionName} Sync`);