From a54de07260c3555d0230492970448604ffb9d586 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 18 Feb 2020 08:41:32 +0900 Subject: [PATCH] Resolve #5963 --- locales/ja-JP.yml | 3 + migration/1581979837262-promo.ts | 28 +++++++++ src/client/components/date-separated-list.vue | 2 +- src/client/components/note.vue | 38 +++++++++++- src/client/components/notes.vue | 2 +- src/db/postgre.ts | 4 ++ src/models/entities/promo-note.ts | 28 +++++++++ src/models/entities/promo-read.ts | 35 +++++++++++ src/models/index.ts | 4 ++ src/models/repositories/note.ts | 1 + src/server/api/common/inject-promo.ts | 36 ++++++++++++ .../api/endpoints/admin/promo/create.ts | 58 +++++++++++++++++++ .../api/endpoints/notes/global-timeline.ts | 4 +- .../api/endpoints/notes/hybrid-timeline.ts | 3 + .../api/endpoints/notes/local-timeline.ts | 3 + src/server/api/endpoints/notes/timeline.ts | 3 + 16 files changed, 247 insertions(+), 5 deletions(-) create mode 100644 migration/1581979837262-promo.ts create mode 100644 src/models/entities/promo-note.ts create mode 100644 src/models/entities/promo-read.ts create mode 100644 src/server/api/common/inject-promo.ts create mode 100644 src/server/api/endpoints/admin/promo/create.ts diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 059ae7e60..288ffd39f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -412,6 +412,9 @@ dayOverDayChanges: "前日比" accessibility: "アクセシビリティ" clinetSettings: "クライアント設定" accountSettings: "アカウント設定" +promotion: "プロモーション" +promote: "プロモート" +numberOfDays: "日数" _ago: unknown: "謎" diff --git a/migration/1581979837262-promo.ts b/migration/1581979837262-promo.ts new file mode 100644 index 000000000..2c4f25c4d --- /dev/null +++ b/migration/1581979837262-promo.ts @@ -0,0 +1,28 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class promo1581979837262 implements MigrationInterface { + name = 'promo1581979837262' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "promo_note" ("noteId" character varying(32) NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL, "userId" character varying(32) NOT NULL, CONSTRAINT "REL_e263909ca4fe5d57f8d4230dd5" UNIQUE ("noteId"), CONSTRAINT "PK_e263909ca4fe5d57f8d4230dd5c" PRIMARY KEY ("noteId"))`, undefined); + await queryRunner.query(`CREATE INDEX "IDX_83f0862e9bae44af52ced7099e" ON "promo_note" ("userId") `, undefined); + await queryRunner.query(`CREATE TABLE "promo_read" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "userId" character varying(32) NOT NULL, "noteId" character varying(32) NOT NULL, CONSTRAINT "PK_61917c1541002422b703318b7c9" PRIMARY KEY ("id"))`, undefined); + await queryRunner.query(`CREATE INDEX "IDX_9657d55550c3d37bfafaf7d4b0" ON "promo_read" ("userId") `, undefined); + await queryRunner.query(`CREATE UNIQUE INDEX "IDX_2882b8a1a07c7d281a98b6db16" ON "promo_read" ("userId", "noteId") `, undefined); + await queryRunner.query(`ALTER TABLE "promo_note" ADD CONSTRAINT "FK_e263909ca4fe5d57f8d4230dd5c" FOREIGN KEY ("noteId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, undefined); + await queryRunner.query(`ALTER TABLE "promo_read" ADD CONSTRAINT "FK_9657d55550c3d37bfafaf7d4b05" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, undefined); + await queryRunner.query(`ALTER TABLE "promo_read" ADD CONSTRAINT "FK_a46a1a603ecee695d7db26da5f4" FOREIGN KEY ("noteId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "promo_read" DROP CONSTRAINT "FK_a46a1a603ecee695d7db26da5f4"`, undefined); + await queryRunner.query(`ALTER TABLE "promo_read" DROP CONSTRAINT "FK_9657d55550c3d37bfafaf7d4b05"`, undefined); + await queryRunner.query(`ALTER TABLE "promo_note" DROP CONSTRAINT "FK_e263909ca4fe5d57f8d4230dd5c"`, undefined); + await queryRunner.query(`DROP INDEX "IDX_2882b8a1a07c7d281a98b6db16"`, undefined); + await queryRunner.query(`DROP INDEX "IDX_9657d55550c3d37bfafaf7d4b0"`, undefined); + await queryRunner.query(`DROP TABLE "promo_read"`, undefined); + await queryRunner.query(`DROP INDEX "IDX_83f0862e9bae44af52ced7099e"`, undefined); + await queryRunner.query(`DROP TABLE "promo_note"`, undefined); + } + +} diff --git a/src/client/components/date-separated-list.vue b/src/client/components/date-separated-list.vue index 461459f3b..c425c02dc 100644 --- a/src/client/components/date-separated-list.vue +++ b/src/client/components/date-separated-list.vue @@ -2,7 +2,7 @@