mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-06 22:07:58 +03:00
Add support for saving custom tables.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Router } from "express";
|
||||
import db from "external/mongo/db";
|
||||
import { SYMBOL_TachiData } from "lib/constants/tachi";
|
||||
import { GetTableFromParam } from "./middleware";
|
||||
import { GetFoldersFromTable } from "utils/folder";
|
||||
import { FilterQuery } from "mongodb";
|
||||
import { TableDocument } from "tachi-common";
|
||||
import { GetFoldersFromTable } from "utils/folder";
|
||||
import { GetTableFromParam } from "./middleware";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
+16
@@ -35,6 +35,7 @@ router.patch(
|
||||
preferredScoreAlg: p.optional(p.nullable(p.isIn(gptConfig.scoreRatingAlgs))),
|
||||
preferredSessionAlg: p.optional(p.nullable(p.isIn(gptConfig.sessionRatingAlgs))),
|
||||
preferredProfileAlg: p.optional(p.nullable(p.isIn(gptConfig.profileRatingAlgs))),
|
||||
defaultTable: "*?string",
|
||||
// This is a pretty stupid IIFE level hack, ah well.
|
||||
gameSpecific: p.any,
|
||||
scoreBucket: optNull(p.isIn("grade", "lamp")),
|
||||
@@ -71,6 +72,21 @@ router.patch(
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof req.body.preferredTable === "string") {
|
||||
const table = await db.tables.findOne({
|
||||
game,
|
||||
playtype,
|
||||
tableID: req.body.preferredTable,
|
||||
});
|
||||
|
||||
if (!table) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
description: `The requested table (${req.body.preferredTable}) does not exist.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const updateQuery: Record<string, string> = {};
|
||||
|
||||
// @warning Slightly icky dynamic prop assignment instead of copypasta.
|
||||
|
||||
Reference in New Issue
Block a user