From 3209addc9479e99597df40810c04280b24e2d577 Mon Sep 17 00:00:00 2001 From: Braian Mellor Date: Mon, 4 Dec 2023 17:47:48 -0300 Subject: [PATCH 1/2] feat: support worlds as highlighted. Add Metadyne Labs - Rat Scape world as highlighted --- src/entities/Place/model.ts | 6 ++++-- ...701722138835_automatic-update-static-places.ts | 15 +++++++++++++++ src/seed/34_places_new.json | 8 ++++++++ src/seed/indexNew.test.ts | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/migrations/1701722138835_automatic-update-static-places.ts create mode 100644 src/seed/34_places_new.json diff --git a/src/entities/Place/model.ts b/src/entities/Place/model.ts index 79861fc6..5400175f 100644 --- a/src/entities/Place/model.ts +++ b/src/entities/Place/model.ts @@ -203,7 +203,8 @@ export default class PlaceModel extends Model { )} WHERE - p."disabled" is false AND "world" is false + p."disabled" is false + ${conditional(!options.only_highlighted, SQL`AND "world" is false`)} ${conditional(options.only_highlighted, SQL`AND highlighted = TRUE`)} ${conditional(!!options.search, SQL`AND rank > 0`)} ${conditional( @@ -273,7 +274,8 @@ export default class PlaceModel extends Model { )} WHERE - p."disabled" is false AND "world" is false + p."disabled" is false + ${conditional(!options.only_highlighted, SQL`AND "world" is false`)} ${conditional(options.only_highlighted, SQL`AND highlighted = TRUE`)} ${conditional( options.positions?.length > 0, diff --git a/src/migrations/1701722138835_automatic-update-static-places.ts b/src/migrations/1701722138835_automatic-update-static-places.ts new file mode 100644 index 00000000..b38638e8 --- /dev/null +++ b/src/migrations/1701722138835_automatic-update-static-places.ts @@ -0,0 +1,15 @@ +import { createPlaceNewMigrationUpdate } from "../entities/Place/migration" +import { PlaceAttributes } from "../entities/Place/types" +import defaultPlace from "../seed/34_places_new.json" + +const attributes: Array = [ + "base_position", + "highlighted_image", + "highlighted", + "world_name", +] + +export const { up, down } = createPlaceNewMigrationUpdate( + defaultPlace, + attributes +) diff --git a/src/seed/34_places_new.json b/src/seed/34_places_new.json new file mode 100644 index 00000000..34315dd7 --- /dev/null +++ b/src/seed/34_places_new.json @@ -0,0 +1,8 @@ +{ + "update": [ + { + "world_name": "MetadyneLabs.dcl.eth", + "highlighted": true + } + ] +} diff --git a/src/seed/indexNew.test.ts b/src/seed/indexNew.test.ts index 2ec76c85..c107fa3f 100644 --- a/src/seed/indexNew.test.ts +++ b/src/seed/indexNew.test.ts @@ -1,6 +1,6 @@ import { validatePlacesWorlds } from "../entities/Place/migration" -const files = ["31_places_new.json", "32_places_new.json"] +const files = ["31_places_new.json", "32_places_new.json", "34_places_new.json"] for (const file of files) { test(`should be able to migrate ${file} places`, async () => { From c76f4a25917dcc0be178cbcf31d673319ec9c8da Mon Sep 17 00:00:00 2001 From: Braian Mellor Date: Mon, 4 Dec 2023 17:48:16 -0300 Subject: [PATCH 2/2] fix: automatic migration --- src/seed/migration.ts.example | 2 -- src/seed/places.json.example | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/seed/migration.ts.example b/src/seed/migration.ts.example index 91f55ffd..0fa8085c 100644 --- a/src/seed/migration.ts.example +++ b/src/seed/migration.ts.example @@ -6,8 +6,6 @@ const attributes: Array = [ "base_position", "highlighted_image", "highlighted", - "featured", - "featured_image", "world_name", ] diff --git a/src/seed/places.json.example b/src/seed/places.json.example index 4968777e..0021cea2 100644 --- a/src/seed/places.json.example +++ b/src/seed/places.json.example @@ -7,11 +7,11 @@ }, { "base_position": "-29,55", - "featured": true + "highlighted": true }, { "world_name": "mgoldman.dcl.eth", - "featured": true, + "highlighted": true, } ] } */