From d583b902ca265bc89996c136bec3a1173bcfbcf3 Mon Sep 17 00:00:00 2001 From: zkldi Date: Thu, 22 Apr 2021 21:38:50 +0100 Subject: [PATCH] push whatever --- server/pnpm-lock.yaml | 6 ++-- server/src/db/schemas.ts | 33 +++++++++++++++++++ .../__KT_DATABASE_MIGRATION/songs-iidx.ts | 6 ++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/server/pnpm-lock.yaml b/server/pnpm-lock.yaml index adf230dab..3198f1595 100644 --- a/server/pnpm-lock.yaml +++ b/server/pnpm-lock.yaml @@ -61,7 +61,7 @@ dependencies: express-async-errors: 3.1.1_express@4.17.1 express-session: 1.17.1 fast-json-stable-hash: 1.0.1 - kamaitachi-common: github.com/zkldi/Kamaitachi-common/7fc1dc8955ead256bc8d84c602095cf4c8e2e509 + kamaitachi-common: github.com/zkldi/Kamaitachi-common/cc4d90ae418e552459ac8c501f8fc75222639148 mongodb: 3.6.6 monk: 7.3.4 multer: 1.4.2 @@ -4601,8 +4601,8 @@ packages: '@types/yoga-layout': 1.9.2 dev: true - github.com/zkldi/Kamaitachi-common/7fc1dc8955ead256bc8d84c602095cf4c8e2e509: - resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/7fc1dc8955ead256bc8d84c602095cf4c8e2e509} + github.com/zkldi/Kamaitachi-common/cc4d90ae418e552459ac8c501f8fc75222639148: + resolution: {tarball: https://codeload.github.com/zkldi/Kamaitachi-common/tar.gz/cc4d90ae418e552459ac8c501f8fc75222639148} name: kamaitachi-common version: 0.1.0 dependencies: diff --git a/server/src/db/schemas.ts b/server/src/db/schemas.ts index 5acd771dc..c6e30878a 100644 --- a/server/src/db/schemas.ts +++ b/server/src/db/schemas.ts @@ -374,6 +374,38 @@ export const PRUDENCE_CHART_SCHEMAS: Record = { }), }; +const PRUDENCE_SONG_BASE: PrudenceSchema = { + id: p.isPositiveInteger, + title: "string", + artist: "string", + isRemoved: "boolean", + "search-titles": [p.and("string", (self, parent) => self !== parent.title)], + "alt-titles": [p.and("string", (self, parent) => self !== parent.title)], + version: ["string"], +}; + +function CreatePrSong(data: PrudenceSchema) { + return deepmerge(PRUDENCE_SONG_BASE, { + data, + }); +} + +const PRUDENCE_SONG_WITH_GENRE = CreatePrSong({ genre: "string" }); + +export const PRUDENCE_SONG_SCHEMAS: Record = { + iidx: PRUDENCE_SONG_WITH_GENRE, + bms: PRUDENCE_SONG_WITH_GENRE, + chunithm: PRUDENCE_SONG_WITH_GENRE, + ddr: CreatePrSong({}), + gitadora: CreatePrSong({}), + jubeat: CreatePrSong({}), + maimai: CreatePrSong({ titleJP: "string", artistJP: "string", genre: "string" }), + museca: CreatePrSong({ titleJP: "string", artistJP: "string" }), + popn: PRUDENCE_SONG_WITH_GENRE, + sdvx: CreatePrSong({ uscEquiv: p.isPositiveInteger }), + usc: CreatePrSong({ sdvxEquiv: p.isPositiveInteger }), +}; + /** * Schemas that are "static", i.e. the content of the document * does not depend on fields in the document (such as score docs) @@ -384,4 +416,5 @@ export const STATIC_SCHEMAS = { "iidx-bpi-data": PRUDENCE_IIDX_BPI_DATA, counters: PRUDENCE_COUNTER, charts: PRUDENCE_CHART_SCHEMAS, + songs: PRUDENCE_SONG_SCHEMAS, }; diff --git a/server/src/scripts/__KT_DATABASE_MIGRATION/songs-iidx.ts b/server/src/scripts/__KT_DATABASE_MIGRATION/songs-iidx.ts index 5b34d533a..31bbd9c56 100644 --- a/server/src/scripts/__KT_DATABASE_MIGRATION/songs-iidx.ts +++ b/server/src/scripts/__KT_DATABASE_MIGRATION/songs-iidx.ts @@ -10,8 +10,10 @@ function ConvertFn(c: any): SongDocument<"iidx"> { artist: c.artist, id: c.id, isRemoved: false, // NOT REALLY - "alt-titles": c["alt-titles"], - "search-titles": c["search-titles"], + "alt-titles": c["alt-titles"].filter((e: string) => e !== c.title), + "search-titles": c["search-titles"] + .map((e: string) => e.toString()) + .filter((e: string) => e !== c.title), version: [], // sentinel data: { genre: c.genre,