diff --git a/sites/backend/prisma/schema.prisma b/sites/backend/prisma/schema.prisma index 22814ce5da0..c47f9341163 100644 --- a/sites/backend/prisma/schema.prisma +++ b/sites/backend/prisma/schema.prisma @@ -121,6 +121,7 @@ model Set { model CuratedSet { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) + height Int @default(1) info String @default("") nameDe String @default("") nameEn String @default("") diff --git a/sites/backend/src/models/curated-set.mjs b/sites/backend/src/models/curated-set.mjs index c02dddff4c9..3e54fe3c6e3 100644 --- a/sites/backend/src/models/curated-set.mjs +++ b/sites/backend/src/models/curated-set.mjs @@ -62,6 +62,11 @@ CuratedSetModel.prototype.guardedCreate = async function ({ body, user }) { */ if (body.info) data.info = body.info + /* + * Add the height + */ + if (body.height) data.height = Number(body.height) + /* * Create the database record */ @@ -122,7 +127,7 @@ CuratedSetModel.prototype.allCuratedSets = async function () { */ let curatedSets try { - curatedSets = await this.prisma.curatedSet.findMany() + curatedSets = await this.prisma.curatedSet.findMany({ orderBy: { height: 'asc' } }) } catch (err) { log.warn(`Failed to search curated sets: ${err}`) } @@ -229,6 +234,11 @@ CuratedSetModel.prototype.guardedUpdate = async function ({ params, body, user } */ if (typeof body.info === 'string') data.info = body.info + /* + * Handle the info field + */ + if (body.height) data.height = Number(body.height) + /* * Unlike a regular set, curated set have notes and name in each language */ @@ -258,7 +268,7 @@ CuratedSetModel.prototype.guardedUpdate = async function ({ params, body, user } await storeImage( { id: `cset-${this.record.id}`, - metadata: { user: this.user.uid }, + metadata: { user: user.uid }, b64: body.img, }, this.isTest(body) @@ -434,6 +444,7 @@ CuratedSetModel.prototype.fromSuggestion = async function ({ params, user }) { * Now create the curated set */ await this.createRecord({ + height: this.Confirmation.record.clear.data.height || 1, nameDe: name, nameEn: name, nameEs: name,