diff --git a/backend/src/entity/entities/VTagsSuperDefault.ts b/backend/src/entity/entities/VTagsSuperDefault.ts index e950f785..00ac5a24 100644 --- a/backend/src/entity/entities/VTagsSuperDefault.ts +++ b/backend/src/entity/entities/VTagsSuperDefault.ts @@ -2,23 +2,29 @@ import { DataSource, ViewColumn, ViewEntity } from 'typeorm'; @ViewEntity('v_tags_super_default', { expression: ` - SELECT sp1.content, ( - SELECT COUNT(sp1.id) + SELECT sp1.content, + (SELECT COUNT(sp1.id) FROM sub_tag sb1 WHERE sb1.superTagId = sp1.id - AND sb1.isDeleted IS FALSE AND sb1.isPublic IS TRUE) AS count - FROM super_tag sp1 - WHERE sp1.isDeleted IS FALSE - AND sp1.content != 'default' + AND sb1.isDeleted IS FALSE + AND sb1.isPublic IS TRUE) AS count, + 1 AS type, + DATE_FORMAT(sp1.createdAt, '%Y-%m-%d') AS createdAt + FROM super_tag sp1 + WHERE sp1.isDeleted IS FALSE + AND sp1.content != 'default' UNION SELECT sb2.content, - 0 AS count - FROM sub_tag sb2 - INNER JOIN super_tag sp2 - ON sb2.superTagId = sp2.id - WHERE sp2.content = 'default' - AND sb2.isDeleted IS FALSE - AND sb2.isPublic IS TRUE`, + 0 AS count, + 0 AS type, + DATE_FORMAT(sb2.createdAt, '%Y-%m-%d') AS createdAt + FROM sub_tag sb2 + INNER JOIN super_tag sp2 + ON sb2.superTagId = sp2.id + WHERE sp2.content = 'default' + AND sb2.isDeleted IS FALSE + AND sb2.isPublic IS TRUE + `, }) export class VTagsSuperDefault { @ViewColumn() @@ -26,6 +32,12 @@ export class VTagsSuperDefault { @ViewColumn() count: number; + + @ViewColumn() + type: string; + + @ViewColumn() + createdAt: string; } export default VTagsSuperDefault;