mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-06 22:07:58 +03:00
fix: make new search engine work
This commit is contained in:
@@ -206,7 +206,6 @@ function ChartView({
|
||||
<tr>
|
||||
<DifficultyCell game={game} chart={d.chart} />
|
||||
<TitleCell chart={d.chart} game={game} song={d.song} />
|
||||
<td>{d.song.__textScore}</td>
|
||||
<td>{d.playcount}</td>
|
||||
</tr>
|
||||
)}
|
||||
|
||||
@@ -28,7 +28,28 @@ t.test("#SearchSpecificGameSongs", (t) => {
|
||||
// songID here and expect this.
|
||||
t.strictSame(
|
||||
res.sort((a, b) => a.id - b.id).map((e) => e.title),
|
||||
["A", "AA", "冥", "F", "HAERETICUS", "ZZ", "X", "AA -rebuild-", "∀", "-65℃"]
|
||||
[
|
||||
"L'amour et la liberte",
|
||||
"A",
|
||||
"I'm In Love Again -Y&Co. EURO MIX-",
|
||||
"AA",
|
||||
"冥",
|
||||
"Make Me Your Own",
|
||||
"AIR RAID FROM THA UNDAGROUND",
|
||||
"Programmed Sun (xac Antarctic Ocean mix)",
|
||||
"黒髪乱れし修羅となりて",
|
||||
"F",
|
||||
"DON'T WAKE ME FROM THE DREAM (2010 Summer Edition)",
|
||||
"HAERETICUS",
|
||||
"狂イ咲ケ焔ノ華",
|
||||
"ZZ",
|
||||
"X",
|
||||
"獅子霞麗ノ舞",
|
||||
"AA -rebuild-",
|
||||
"抱きしめてモナムール",
|
||||
"∀",
|
||||
"-65℃",
|
||||
]
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/* eslint-disable import/first */
|
||||
// see: https://www.npmjs.com/package/fix-esm
|
||||
// fzf *mandates* esm, but we don't use it (ts transpiles to cjs)
|
||||
// sick of this headache.
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
require("fix-esm").register();
|
||||
|
||||
import db from "external/mongo/db";
|
||||
import { AsyncFzf } from "fzf";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
@@ -37,7 +44,7 @@ const SEARCH_CONTROLS = {
|
||||
goals: { keys: ["name"], primary: "goalID" },
|
||||
quests: { keys: ["name"], primary: "questID" },
|
||||
users: { keys: ["username"], primary: "id" },
|
||||
folders: { keys: ["name", "searchTerms"], primary: "folderID" },
|
||||
folders: { keys: ["title", "searchTerms"], primary: "folderID" },
|
||||
} satisfies Partial<Record<keyof typeof db, SearchControls>>;
|
||||
|
||||
/**
|
||||
@@ -78,9 +85,13 @@ export async function SearchCollection<T extends object>(
|
||||
}
|
||||
);
|
||||
|
||||
const results = await fzf
|
||||
.find(search)
|
||||
.then((data) => data.filter((d) => d.score > 100));
|
||||
let results = await fzf.find(search);
|
||||
|
||||
// filter out anything far from the best match
|
||||
// 30 was chosen arbitrarily :)
|
||||
const max = results[0]?.score ?? 0;
|
||||
|
||||
results = results.filter((e) => e.score >= max - 30);
|
||||
|
||||
for (const res of results) {
|
||||
const pkey = res.item[controls.primary];
|
||||
|
||||
@@ -3,12 +3,6 @@
|
||||
// we're running as a server, and not as a job runner or score worker.
|
||||
process.env.IS_SERVER = "true";
|
||||
|
||||
// see: https://www.npmjs.com/package/fix-esm
|
||||
// fzf *mandates* esm, but we don't use it (ts transpiles to cjs)
|
||||
// sick of this headache.
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
require("fix-esm").register();
|
||||
|
||||
import db, { monkDB } from "external/mongo/db";
|
||||
import { UpdateIndexes } from "external/mongo/indexes";
|
||||
import { InitSequenceDocs } from "external/mongo/sequence-docs";
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
/* eslint-disable import/first */
|
||||
// see: https://www.npmjs.com/package/fix-esm
|
||||
// fzf *mandates* esm, but we don't use it (ts transpiles to cjs)
|
||||
// sick of this headache.
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
require("fix-esm").register();
|
||||
|
||||
import "external/mongo/db";
|
||||
import { CleanUpAfterTests } from "./cleanup";
|
||||
import glob from "glob";
|
||||
|
||||
Reference in New Issue
Block a user