Skip to content

Commit

Permalink
Added session-feedback entity and migration (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckirby19 authored Jul 4, 2024
1 parent f969d7d commit 789e943
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/entities/session-feedback.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Column, Entity, JoinTable, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { FEEDBACK_TAGS_ENUM } from '../utils/constants';
import { BaseBloomEntity } from './base.entity';
import { SessionEntity } from './session.entity';

@Entity({ name: 'session_feedback' })
export class SessionFeedbackEntity extends BaseBloomEntity {
@PrimaryGeneratedColumn('uuid', { name: 'sessionFeedbackId' })
sessionFeedbackId: string;

@Column()
sessionId: string;
@ManyToOne(() => SessionEntity, (sessionEntity) => sessionEntity.sessionUser, {
onDelete: 'CASCADE',
})
@JoinTable({ name: 'session', joinColumn: { name: 'sessionId' } })
session: SessionEntity;

@Column()
feedbackTags: FEEDBACK_TAGS_ENUM;

@Column()
feedbackDescription: string;
}
16 changes: 16 additions & 0 deletions src/migrations/1719668310816-bloom-backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class BloomBackend1719668310816 implements MigrationInterface {
name = 'BloomBackend1719668310816'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "session_feedback" ("createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "sessionFeedbackId" uuid NOT NULL DEFAULT uuid_generate_v4(), "sessionId" uuid NOT NULL, "feedbackTags" character varying NOT NULL, "feedbackDescription" character varying NOT NULL, CONSTRAINT "PK_fa9bf9afa42e7a30230cf243090" PRIMARY KEY ("sessionFeedbackId"))`);
await queryRunner.query(`ALTER TABLE "session_feedback" ADD CONSTRAINT "FK_a0567dbf6bd30cf4bd05b110a17" FOREIGN KEY ("sessionId") REFERENCES "session"("sessionId") ON DELETE CASCADE ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "session_feedback" DROP CONSTRAINT "FK_a0567dbf6bd30cf4bd05b110a17"`);
await queryRunner.query(`DROP TABLE "session_feedback"`);
}

}
4 changes: 4 additions & 0 deletions src/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PartnerAccessEntity } from './entities/partner-access.entity';
import { PartnerAdminEntity } from './entities/partner-admin.entity';
import { PartnerFeatureEntity } from './entities/partner-feature.entity';
import { PartnerEntity } from './entities/partner.entity';
import { SessionFeedbackEntity } from './entities/session-feedback.entity';
import { SessionUserEntity } from './entities/session-user.entity';
import { SessionEntity } from './entities/session.entity';
import { SubscriptionUserEntity } from './entities/subscription-user.entity';
Expand Down Expand Up @@ -46,6 +47,7 @@ import { bloomBackend1698136145516 } from './migrations/1698136145516-bloom-back
import { bloomBackend1706174260018 } from './migrations/1706174260018-bloom-backend';
import { BloomBackend1718300621138 } from './migrations/1718300621138-bloom-backend';
import { BloomBackend1718728423454 } from './migrations/1718728423454-bloom-backend';
import { BloomBackend1719668310816 } from './migrations/1719668310816-bloom-backend';

config();
const configService = new ConfigService();
Expand Down Expand Up @@ -83,6 +85,7 @@ export const dataSourceOptions = {
SubscriptionEntity,
SubscriptionUserEntity,
TherapySessionEntity,
SessionFeedbackEntity,
],
migrations: [
bloomBackend1637704119795,
Expand Down Expand Up @@ -114,6 +117,7 @@ export const dataSourceOptions = {
bloomBackend1706174260018,
BloomBackend1718300621138,
BloomBackend1718728423454,
BloomBackend1719668310816,
],
subscribers: [],
ssl: isProduction || isStaging,
Expand Down
9 changes: 9 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export enum SIMPLYBOOK_ACTION_ENUM {
COMPLETED_BOOKING = 'COMPLETED_BOOKING', // currently not in use as no webhook available - could be updated in cron job
}

export enum FEEDBACK_TAGS_ENUM {
RELATABLE = 'relatable',
USEFUL = 'useful',
INSPIRING = 'inspiring',
TOO_LONG = 'too long',
TOO_COMPLICATED = 'too complicated',
NOT_USEFUL = 'not useful',
}

export enum STORYBLOK_STORY_STATUS_ENUM {
PUBLISHED = 'published',
UNPUBLISHED = 'unpublished',
Expand Down

0 comments on commit 789e943

Please sign in to comment.