From 0a51576343233531636bb9219454ddc82e95ccae Mon Sep 17 00:00:00 2001 From: Paulo Endoh Date: Thu, 4 Apr 2024 16:09:26 -0300 Subject: [PATCH] Rename everything from 'note' to 'question' [cl9fdtpzc98900myzkzgiqxfu] --- .../define/flashnotes/FlashnotesController.ts | 54 +-- .../define/flashnotes/FlashnotesService.ts | 63 +-- .../flashnotes/types/CreateManyNotesDto.ts | 4 +- src/domains/doc/DocController.ts | 14 +- src/domains/doc/DocService.ts | 6 +- src/entities/User.ts | 6 +- src/entities/define/Doc.ts | 30 +- src/entities/define/{Note.ts => Question.ts} | 8 +- src/migrations/1712256141255-Migration.ts | 14 + ...oteRepository.ts => QuestionRepository.ts} | 365 +++++++++--------- src/subscriber/UserSubscriber.ts | 5 +- 11 files changed, 301 insertions(+), 268 deletions(-) rename src/entities/define/{Note.ts => Question.ts} (89%) create mode 100644 src/migrations/1712256141255-Migration.ts rename src/repositories/define/{NoteRepository.ts => QuestionRepository.ts} (53%) diff --git a/src/domains/define/flashnotes/FlashnotesController.ts b/src/domains/define/flashnotes/FlashnotesController.ts index 2521ccc..cbfb026 100644 --- a/src/domains/define/flashnotes/FlashnotesController.ts +++ b/src/domains/define/flashnotes/FlashnotesController.ts @@ -10,11 +10,11 @@ import { Put, QueryParam, } from "routing-controllers" -import { Note } from "../../../entities/define/Note" import { User } from "../../../entities/User" -import { getNoteRepository } from "../../../repositories/define/NoteRepository" +import { Question } from "../../../entities/define/Question" +import { getQuestionRepository } from "../../../repositories/define/QuestionRepository" import { FlashnotesService } from "./FlashnotesService" -import { CreateManyNotesDto } from "./types/CreateManyNotesDto" +import { CreateManyQuestionsDto } from "./types/CreateManyNotesDto" import { FlashnotesSearchType } from "./types/FlashnotesSearchType" @JsonController() @@ -22,7 +22,7 @@ export class FlashnotesController { constructor( private flashnotesService = new FlashnotesService(), - private noteRepo = getNoteRepository() + private questionRepo = getQuestionRepository() ) {} @Get("/flashnotes/search") @@ -39,49 +39,53 @@ export class FlashnotesController { }) } - @Get("/define/note") - async getAllNotes( + @Get("/define/question") + async getAllQuestions( @CurrentUser({ required: true }) user: User ) { - return this.noteRepo.getAllNotesFromUserId(user.id) + return this.questionRepo.getAllQuestionsFromUserId(user.id) } - @Post("/define/note") - async saveNote( + @Post("/define/question") + async saveQuestion( @CurrentUser({ required: true }) user: User, - @Body() sentNote: Note + @Body() sentQuestion: Question ) { - if (sentNote.id) - return this.flashnotesService.updateQuestion(sentNote, user.id) + if (sentQuestion.id) + return this.flashnotesService.updateQuestion(sentQuestion, user.id) - return this.flashnotesService.createQuestion(sentNote, user.id) + return this.flashnotesService.createQuestion(sentQuestion, user.id) } - @Put("/define/note/many") - async updateManyNotes( + @Put("/define/question/many") + async updateManyQuestions( @CurrentUser({ required: true }) user: User, - @Body() sentNotes: Note[] + @Body() sentQuestions: Question[] ) { - const isOwner = await getNoteRepository().isOwner(sentNotes, user.id) - if (!isOwner) throw new ForbiddenError("User is not owner of all notes.") + const isOwner = await getQuestionRepository().isOwner( + sentQuestions, + user.id + ) + if (!isOwner) + throw new ForbiddenError("User is not owner of all questions.") - await this.noteRepo.save(sentNotes) - return this.noteRepo.getAllNotesFromUserId(user.id) + await this.questionRepo.save(sentQuestions) + return this.questionRepo.getAllQuestionsFromUserId(user.id) } - @Post("/define/doc/:docId/notes/many") - async createManyNotes( + @Post("/define/doc/:docId/questions/many") + async createManyQuestions( @CurrentUser({ required: true }) user: User, - @Body() body: CreateManyNotesDto, + @Body() body: CreateManyQuestionsDto, @Param("docId") docId: number ) { - return this.flashnotesService.createManyNotes( + return this.flashnotesService.createManyQuestions( docId, - body.notesQuantity, + body.questionsQuantity, user.id ) } diff --git a/src/domains/define/flashnotes/FlashnotesService.ts b/src/domains/define/flashnotes/FlashnotesService.ts index 00d8caf..a3dfc59 100644 --- a/src/domains/define/flashnotes/FlashnotesService.ts +++ b/src/domains/define/flashnotes/FlashnotesService.ts @@ -1,39 +1,41 @@ import { NotFoundError } from "routing-controllers" -import { Note } from "../../../entities/define/Note" +import { Question } from "../../../entities/define/Question" import DocRepository from "../../../repositories/define/DocRepository" -import NoteRepository from "../../../repositories/define/NoteRepository" +import QuestionRepository from "../../../repositories/define/QuestionRepository" import { FlashnotesSearchType } from "./types/FlashnotesSearchType" export class FlashnotesService { constructor( - private noteRepository = NoteRepository, + private questionRepo = QuestionRepository, private docRepo = DocRepository ) {} - async createQuestion(sentNote: Note, requesterId: number) { - sentNote.userId = requesterId + async createQuestion(sentQuestion: Question, requesterId: number) { + sentQuestion.userId = requesterId - const noteWithHighestIndex = - await this.noteRepository.findNoteWithHighestIndex(sentNote.docId) + const questionWithHighestIndex = + await this.questionRepo.findQuestionWithHighestIndex(sentQuestion.docId) - sentNote.index = noteWithHighestIndex ? noteWithHighestIndex.index + 1 : 0 + sentQuestion.index = questionWithHighestIndex + ? questionWithHighestIndex.index + 1 + : 0 - return this.noteRepository.save({ - ...sentNote, + return this.questionRepo.save({ + ...sentQuestion, doc: undefined, }) } - async updateQuestion(sentNote: Note, requesterId: number) { - const found = await this.noteRepository.findOne({ - where: { userId: requesterId, id: sentNote.id }, + async updateQuestion(sentQuestion: Question, requesterId: number) { + const found = await this.questionRepo.findOne({ + where: { userId: requesterId, id: sentQuestion.id }, }) if (!found) - throw new NotFoundError("Note doesn't exist or user is not owner") + throw new NotFoundError("Question doesn't exist or user is not owner") - return this.noteRepository.save({ - ...sentNote, + return this.questionRepo.save({ + ...sentQuestion, userId: requesterId, doc: undefined, }) @@ -49,25 +51,29 @@ export class FlashnotesService { if (type === "questions") { return { docs: [], - notes: await this.noteRepository.searchNotesByQuestionText( + questions: await this.questionRepo.searchQuestionsByQuestionText( query, requesterId ), } } - const [docs, notes] = await Promise.all([ + const [docs, questions] = await Promise.all([ this.docRepo.searchDocs(query, requesterId), - this.noteRepository.searchNotes(query, requesterId), + this.questionRepo.searchQuestions(query, requesterId), ]) return { docs, - notes, + questions, } } - async createManyNotes(docId: number, quantity: number, requesterId: number) { + async createManyQuestions( + docId: number, + quantity: number, + requesterId: number + ) { const doc = await this.docRepo.findOne({ where: { id: docId, @@ -77,26 +83,25 @@ export class FlashnotesService { if (!doc) throw new NotFoundError("Doc not found or user is not owner") - const highestIndexNote = await this.noteRepository.findNoteWithHighestIndex( - docId - ) + const highestIndexQuestion = + await this.questionRepo.findQuestionWithHighestIndex(docId) - return this.noteRepository.createEmptyNotes({ + return this.questionRepo.createEmptyQuestions({ docId, userId: requesterId, - initialIndex: highestIndexNote ? highestIndexNote.index + 1 : 0, + initialIndex: highestIndexQuestion ? highestIndexQuestion.index + 1 : 0, quantity: quantity, }) } deleteQuestion = async (questionId: number, requesterId: number) => { - const found = await this.noteRepository.findOne({ + const found = await this.questionRepo.findOne({ where: { userId: requesterId, id: questionId }, }) if (!found) - throw new NotFoundError("Note doesn't exist or user is not owner") + throw new NotFoundError("Question doesn't exist or user is not owner") - return this.noteRepository.delete(questionId) + return this.questionRepo.delete(questionId) } } diff --git a/src/domains/define/flashnotes/types/CreateManyNotesDto.ts b/src/domains/define/flashnotes/types/CreateManyNotesDto.ts index 4d6779e..889b389 100644 --- a/src/domains/define/flashnotes/types/CreateManyNotesDto.ts +++ b/src/domains/define/flashnotes/types/CreateManyNotesDto.ts @@ -1,7 +1,7 @@ import { IsNumber, Max } from "class-validator" -export class CreateManyNotesDto { +export class CreateManyQuestionsDto { @IsNumber() @Max(25) - notesQuantity: number + questionsQuantity: number } diff --git a/src/domains/doc/DocController.ts b/src/domains/doc/DocController.ts index b7a08f1..ca78391 100644 --- a/src/domains/doc/DocController.ts +++ b/src/domains/doc/DocController.ts @@ -11,11 +11,11 @@ import { Req, UseBefore, } from "routing-controllers" -import { Doc } from "../../entities/define/Doc" import { User } from "../../entities/User" +import { Doc } from "../../entities/define/Doc" import { MyAuthMiddleware } from "../../middlewares/MyAuthMiddleware" import { getDocRepository } from "../../repositories/define/DocRepository" -import { getNoteRepository } from "../../repositories/define/NoteRepository" +import { getQuestionRepository } from "../../repositories/define/QuestionRepository" import { MyAuthRequest } from "../../utils/MyAuthRequest" import { DocService } from "./DocService" @@ -24,7 +24,7 @@ export class DocController { constructor( private docService = new DocService(), private docRepository = getDocRepository(), - private noteRepo = getNoteRepository() + private questionRepo = getQuestionRepository() ) {} @Delete("/docs/:docId") @@ -83,13 +83,13 @@ export class DocController { return saved } - @Delete("/define/doc/:id/clear-empty-notes") - async clearEmptyNotes( + @Delete("/define/doc/:id/clear-empty-questions") + async clearEmptyQuestions( @CurrentUser({ required: true }) user: User, @Param("id") docId: number ) { - await this.noteRepo.removeEmptyNotesFromDocId(docId, user.id) + await this.questionRepo.removeEmptyQuestionsFromDocId(docId, user.id) - return this.noteRepo.getAllNotesFromUserId(user.id) + return this.questionRepo.getAllQuestionsFromUserId(user.id) } } diff --git a/src/domains/doc/DocService.ts b/src/domains/doc/DocService.ts index fcf9b4b..8a23236 100644 --- a/src/domains/doc/DocService.ts +++ b/src/domains/doc/DocService.ts @@ -25,7 +25,11 @@ export class DocService { const savedDoc = await this.docRepository.save(newDoc) - await this.flashnotesService.createManyNotes(savedDoc.id, 10, requesterId) + await this.flashnotesService.createManyQuestions( + savedDoc.id, + 10, + requesterId + ) return savedDoc } } diff --git a/src/entities/User.ts b/src/entities/User.ts index e5a2377..1b8184c 100644 --- a/src/entities/User.ts +++ b/src/entities/User.ts @@ -19,7 +19,7 @@ import { Test } from "./Test" import { UserGotIt } from "./UserGotIt" import { UserPreference } from "./UserPreference" import { Doc } from "./define/Doc" -import { Note } from "./define/Note" +import { Question } from "./define/Question" import { Follow } from "./feed/Follow" import { FollowingTag } from "./feed/FollowingTag" import { LastSeenResource } from "./feed/LastSeenResource" @@ -165,8 +165,8 @@ export class User { @OneToMany((_) => Doc, (doc) => doc.user) docs: Doc[] - @OneToMany((_) => Note, (note) => note.user) - notes: Note[] + @OneToMany((_) => Question, (question) => question.user) + questions: Question[] // BigDecisions @OneToMany((_) => Decision, (decision) => decision.user) diff --git a/src/entities/define/Doc.ts b/src/entities/define/Doc.ts index 9e52b5d..b2816f6 100644 --- a/src/entities/define/Doc.ts +++ b/src/entities/define/Doc.ts @@ -6,42 +6,42 @@ import { OneToMany, PrimaryGeneratedColumn, UpdateDateColumn, -} from "typeorm"; -import { Folder } from "../playground/file-system/Folder"; -import { User } from "../User"; -import { Note } from "./Note"; +} from "typeorm" +import { User } from "../User" +import { Folder } from "../playground/file-system/Folder" +import { Question } from "./Question" @Entity() export class Doc { @PrimaryGeneratedColumn() - id: number; + id: number @ManyToOne((type) => User, (user) => user.docs, { onDelete: "CASCADE", }) - user: User; + user: User @Column() - userId: number; + userId: number @ManyToOne(() => Folder, (folder) => folder.docs, { nullable: true }) - folder: Folder | null; + folder: Folder | null @Column({ nullable: true }) - folderId: number | null; + folderId: number | null - @OneToMany(() => Note, (note) => note.doc) - notes: Note[]; + @OneToMany(() => Question, (question) => question.doc) + questions: Question[] // END OF RELATIONS @Column() - title: string; + title: string @CreateDateColumn() - createdAt: string; + createdAt: string @UpdateDateColumn() - updatedAt: string; + updatedAt: string @Column({ type: "timestamp without time zone", nullable: true }) - lastOpenedAt: string; + lastOpenedAt: string } diff --git a/src/entities/define/Note.ts b/src/entities/define/Question.ts similarity index 89% rename from src/entities/define/Note.ts rename to src/entities/define/Question.ts index 48732c2..ab20fe0 100644 --- a/src/entities/define/Note.ts +++ b/src/entities/define/Question.ts @@ -9,8 +9,10 @@ import { import { User } from "../User" import { Doc } from "./Doc" -@Entity() -export class Note { +@Entity({ + name: "question", +}) +export class Question { @PrimaryGeneratedColumn() id: number @@ -21,7 +23,7 @@ export class Note { @Column() userId: number - @ManyToOne(() => Doc, (doc) => doc.notes, { + @ManyToOne(() => Doc, (doc) => doc.questions, { onDelete: "CASCADE", }) doc: Doc diff --git a/src/migrations/1712256141255-Migration.ts b/src/migrations/1712256141255-Migration.ts new file mode 100644 index 0000000..fb5edcd --- /dev/null +++ b/src/migrations/1712256141255-Migration.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm" + +export class Migration1712256141255 implements MigrationInterface { + name = "Migration1712256141255" + + public async up(queryRunner: QueryRunner): Promise { + // rename table notes to questions + await queryRunner.query(`ALTER TABLE "note" RENAME TO "question"`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "question" RENAME TO "note"`) + } +} diff --git a/src/repositories/define/NoteRepository.ts b/src/repositories/define/QuestionRepository.ts similarity index 53% rename from src/repositories/define/NoteRepository.ts rename to src/repositories/define/QuestionRepository.ts index 02115b2..7327f19 100644 --- a/src/repositories/define/NoteRepository.ts +++ b/src/repositories/define/QuestionRepository.ts @@ -1,180 +1,185 @@ -import { dataSource } from "../../dataSource" -import { Doc } from "../../entities/define/Doc" -import { Note } from "../../entities/define/Note" -import { User } from "../../entities/User" - -export const getNoteRepository = () => NoteRepository - -const NoteRepository = dataSource.getRepository(Note).extend({ - async getAllNotesFromUserId(userId: number): Promise { - return this.createQueryBuilder("note") - .where({ userId }) - .orderBy("note.docId", "ASC") - .addOrderBy("note.index", "ASC") - .getMany() - }, - async isOwner(notes: Note[], userId: number): Promise { - const ids = notes.map((note) => note.id) - - if (ids.length === 0) return true - - const count = await this.createQueryBuilder("note") - .where("note.id IN (:...ids)", { ids }) - .andWhere("note.userId = :userId", { userId }) - .getCount() - - return ids.length === count - }, - - async createNotesForNewUser(user: User, doc: Doc): Promise { - const notes: Note[] = [] - - notes.push( - await this.save({ - user, - doc, - index: 0, - description: `[Tip] You can create study notes here! Also, you can create flashcard questions to test yourself, but they are not obligatory like in other tools! \nTest Yourself!`, - }) - ) - - notes.push( - await this.save({ - user, - doc, - index: 1, - description: `All grown-ups were once children... but only few of them remember it.`, - question: "What do the grown-ups forget?", - }) - ) - - notes.push( - await this.save({ - user, - doc, - index: 2, - description: `"I am looking for friends. What does that mean -- tame?" - \n\n"It is an act too often neglected," said the fox. \n\n"It means to establish ties." - - \n\n"To establish ties?" - - \n\n"Just that," said the fox. - \n\n"To me, you are still nothing more than a little boy who is just like a hundred thousand other little boys. And I have no need of you. And you, on your part, have no need of me. To you I am nothing more than a fox like a hundred thousand other foxes. But if you tame me, then we shall need each other. To me, you will be unique in all the world. To you, I shall be unique in all the world...."`, - question: 'What means to "tame" ?', - }) - ) - - notes.push( - await this.save({ - user, - doc, - index: 3, - description: - "“Well, I must endure the presence of a few caterpillars if I wish to become acquainted with the butterflies.”", - question: "What must you endure to get butterflies?", - }) - ) - - return notes - }, - - async removeEmptyNotesFromDocId(docId: number, userId: number) { - await this.createQueryBuilder() - .delete() - .where("docId = :docId", { docId }) - .andWhere("userId = :userId", { userId }) - .andWhere("trim(description) = ''") - .andWhere("trim(question) = ''") - .execute() - - // normalize indexes - const notes = await this.find({ where: { docId, userId } }) - const newNotes = notes.map((note, index) => ({ ...note, index })) - await this.save(newNotes) - }, - - async searchNotesByQuestionText(text: string, userId: number) { - const words = text.split(" ") - - let query = NoteRepository.createQueryBuilder("note").where({ userId }) - - words.forEach((word, index) => { - query = query.andWhere( - `(unaccent(note.question) ilike unaccent(:text${index}))`, - { - [`text${index}`]: `%${word}%`, - } - ) - }) - - query = query - .leftJoinAndSelect("note.doc", "doc") - .orderBy('note."updatedAt"', "DESC") - - return query.getMany() - }, - - async searchNotes(text: string, userId: number) { - const words = text.split(" ") - - let query = NoteRepository.createQueryBuilder("note") - .leftJoinAndSelect("note.doc", "doc") - .where({ userId }) - - // multi word search - words.forEach((word, index) => { - // https://github.com/typeorm/typeorm/issues/3119 - query = query.andWhere( - `(unaccent(note.description) ilike unaccent(:text${index}) - or unaccent(note.question) ilike unaccent(:text${index}) - or unaccent(doc.title) ilike unaccent(:text${index}) - )`, - { - [`text${index}`]: `%${word}%`, - } - ) - }) - - query = query.orderBy('note."updatedAt"', "DESC") - - return query.getMany() - }, - - async findNoteWithHighestIndex(docId: number) { - return NoteRepository.findOne({ - where: { - docId, - }, - order: { - index: "DESC", - }, - }) - }, - - async createEmptyNotes(args: { - quantity: number - docId: number - userId: number - initialIndex: number - }) { - const { quantity, docId, userId, initialIndex } = args - - let notes: Note[] = [] - - await this.manager.transaction(async (manager) => { - for (let i = initialIndex; i < initialIndex + quantity; i++) { - const newNote = new Note() - newNote.userId = userId - newNote.docId = docId - newNote.index = i - newNote.description = "" - const savedNote = await manager.save(newNote) - notes.push(savedNote) - } - }) - - return notes - }, -}) - -export default NoteRepository +import { dataSource } from "../../dataSource" +import { Doc } from "../../entities/define/Doc" +import { Question } from "../../entities/define/Question" +import { User } from "../../entities/User" + +export const getQuestionRepository = () => QuestionRepository + +const QuestionRepository = dataSource.getRepository(Question).extend({ + async getAllQuestionsFromUserId(userId: number): Promise { + return this.createQueryBuilder("question") + .where({ userId }) + .orderBy("question.docId", "ASC") + .addOrderBy("question.index", "ASC") + .getMany() + }, + async isOwner(questions: Question[], userId: number): Promise { + const ids = questions.map((question) => question.id) + + if (ids.length === 0) return true + + const count = await this.createQueryBuilder("question") + .where("question.id IN (:...ids)", { ids }) + .andWhere("question.userId = :userId", { userId }) + .getCount() + + return ids.length === count + }, + + async createQuestionsForNewUser(user: User, doc: Doc): Promise { + const questions: Question[] = [] + + questions.push( + await this.save({ + user, + doc, + index: 0, + description: `[Tip] You can create study questions here! Also, you can create flashcard questions to test yourself, but they are not obligatory like in other tools! \nTest Yourself!`, + }) + ) + + questions.push( + await this.save({ + user, + doc, + index: 1, + description: `All grown-ups were once children... but only few of them remember it.`, + question: "What do the grown-ups forget?", + }) + ) + + questions.push( + await this.save({ + user, + doc, + index: 2, + description: `"I am looking for friends. What does that mean -- tame?" + \n\n"It is an act too often neglected," said the fox. \n\n"It means to establish ties." + + \n\n"To establish ties?" + + \n\n"Just that," said the fox. + \n\n"To me, you are still nothing more than a little boy who is just like a hundred thousand other little boys. And I have no need of you. And you, on your part, have no need of me. To you I am nothing more than a fox like a hundred thousand other foxes. But if you tame me, then we shall need each other. To me, you will be unique in all the world. To you, I shall be unique in all the world...."`, + question: 'What means to "tame" ?', + }) + ) + + questions.push( + await this.save({ + user, + doc, + index: 3, + description: + "“Well, I must endure the presence of a few caterpillars if I wish to become acquainted with the butterflies.”", + question: "What must you endure to get butterflies?", + }) + ) + + return questions + }, + + async removeEmptyQuestionsFromDocId(docId: number, userId: number) { + await this.createQueryBuilder() + .delete() + .where("docId = :docId", { docId }) + .andWhere("userId = :userId", { userId }) + .andWhere("trim(description) = ''") + .andWhere("trim(question) = ''") + .execute() + + // normalize indexes + const questions = await this.find({ where: { docId, userId } }) + const newQuestions = questions.map((question, index) => ({ + ...question, + index, + })) + await this.save(newQuestions) + }, + + async searchQuestionsByQuestionText(text: string, userId: number) { + const words = text.split(" ") + + let query = QuestionRepository.createQueryBuilder("question").where({ + userId, + }) + + words.forEach((word, index) => { + query = query.andWhere( + `(unaccent(question.question) ilike unaccent(:text${index}))`, + { + [`text${index}`]: `%${word}%`, + } + ) + }) + + query = query + .leftJoinAndSelect("question.doc", "doc") + .orderBy('question."updatedAt"', "DESC") + + return query.getMany() + }, + + async searchQuestions(text: string, userId: number) { + const words = text.split(" ") + + let query = QuestionRepository.createQueryBuilder("question") + .leftJoinAndSelect("question.doc", "doc") + .where({ userId }) + + // multi word search + words.forEach((word, index) => { + // https://github.com/typeorm/typeorm/issues/3119 + query = query.andWhere( + `(unaccent(question.description) ilike unaccent(:text${index}) + or unaccent(question.question) ilike unaccent(:text${index}) + or unaccent(doc.title) ilike unaccent(:text${index}) + )`, + { + [`text${index}`]: `%${word}%`, + } + ) + }) + + query = query.orderBy('question."updatedAt"', "DESC") + + return query.getMany() + }, + + async findQuestionWithHighestIndex(docId: number) { + return QuestionRepository.findOne({ + where: { + docId, + }, + order: { + index: "DESC", + }, + }) + }, + + async createEmptyQuestions(args: { + quantity: number + docId: number + userId: number + initialIndex: number + }) { + const { quantity, docId, userId, initialIndex } = args + + let questions: Question[] = [] + + await this.manager.transaction(async (manager) => { + for (let i = initialIndex; i < initialIndex + quantity; i++) { + const newQuestion = new Question() + newQuestion.userId = userId + newQuestion.docId = docId + newQuestion.index = i + newQuestion.description = "" + const savedQuestion = await manager.save(newQuestion) + questions.push(savedQuestion) + } + }) + + return questions + }, +}) + +export default QuestionRepository diff --git a/src/subscriber/UserSubscriber.ts b/src/subscriber/UserSubscriber.ts index 7829c8f..29cc1b3 100644 --- a/src/subscriber/UserSubscriber.ts +++ b/src/subscriber/UserSubscriber.ts @@ -4,9 +4,9 @@ import { InsertEvent, } from "typeorm" import { EmailService } from "../domains/email/EmailService" -import { Profile } from "../entities/feed/Profile" import { User } from "../entities/User" import { UserPreference } from "../entities/UserPreference" +import { Profile } from "../entities/feed/Profile" import { myConsoleError } from "../utils/myConsoleError" @EventSubscriber() @@ -54,8 +54,7 @@ export class UserSubscriber implements EntitySubscriberInterface { // Create little prince doc // const doc = await DocRepository.createDocForNewUser(event.entity) - // Create little prince notes - // await NoteRepository.createNotesForNewUser(event.entity, doc) + } catch (e) { myConsoleError(e.message) }