Skip to content

Commit

Permalink
update (note parents): modification based on previous review, chore m…
Browse files Browse the repository at this point in the history
…odification of logic
  • Loading branch information
dependentmadani committed Sep 26, 2024
1 parent 5bb6be5 commit fee9bbf
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 240 deletions.
13 changes: 4 additions & 9 deletions src/domain/service/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type User from '@domain/entities/user.js';
import type { NoteList } from '@domain/entities/noteList.js';
import type NoteHistoryRepository from '@repository/noteHistory.repository.js';
import type { NoteHistoryMeta, NoteHistoryRecord, NoteHistoryPublic } from '@domain/entities/noteHistory.js';
import type { NotePublic } from '@domain/entities/notePublic.js';
import { definePublicNote, type NotePublic } from '@domain/entities/notePublic.js';

/**
* Note service
Expand Down Expand Up @@ -450,15 +450,10 @@ export default class NoteService {
* @returns - array of notes that are parent structure of the note
*/
public async getNoteParents(noteId: NoteInternalId): Promise<NotePublic[]> {
const noteParents = await this.noteRepository.getNoteParents(noteId);
const noteIds: NoteInternalId[] = await this.noteRelationsRepository.getNoteParentsIds(noteId);
const noteParents = await this.noteRelationsRepository.getNotesByIds(noteIds);
const noteParentsPublic: NotePublic[] = noteParents.map((note) => {
return {
content: note.content,
id: note.publicId,
creatorId: note.creatorId,
createdAt: note.createdAt,
updatedAt: note.updatedAt,
};
return definePublicNote(note);
});

return noteParentsPublic;
Expand Down
Loading

0 comments on commit fee9bbf

Please sign in to comment.