Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(recent-notes): save and delete note visits on the appropriate routes #241

Merged
merged 9 commits into from
Apr 7, 2024

Conversation

e11sy
Copy link
Contributor

@e11sy e11sy commented Apr 4, 2024

Problem

  • Note visits are not saved, when user opened or created the note
  • Note visits are not deleted, when user deletes note

Solution

  • Now on GET note by noteId and GET note by hostname endpoint new noteVisit record inserts to db
  • Now on DELETE note route all noteVisits of this note are deleted
  • VisitedAt now could be literal since in create and update query we can not makevisitedAt field with string

Extra

  • Changed postgres NOW() function to CURRENT_TIMESTAMP() because it represents full timestamp (date with time) and NOW() returns only date
  • left todo to use event bus for deleting and saving noteVisits on appropriate routes

e11sy added 2 commits April 3, 2024 21:13
- added method for deletion of all note visits for certain note
- added saving of note visits on post note and get note endpoints
- bad fix of the problem with camelcase to snake translation (in conflict where)
Copy link

github-actions bot commented Apr 4, 2024

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 86.65% (🎯 80%)
⬆️ +0.87%
7227 / 8340
🟢 Statements 86.65% (🎯 80%)
⬆️ +0.87%
7227 / 8340
🟢 Functions 80.53% (🎯 80%)
⬆️ +2.46%
240 / 298
🟢 Branches 85.37% (🎯 80%)
⬇️ -0.37%
362 / 424
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/domain/index.ts 100% 100% 100% 100%
src/domain/service/note.ts 95.55% 79.16% 100% 95.55% 67-68, 95-96, 102-103, 118-119, 142-143
src/domain/service/noteVisits.ts 100% 100% 100% 100%
src/presentation/http/http-api.ts 95.9% 90.32% 93.75% 95.9% 95-103, 115-116, 306-307, 331-332
src/presentation/http/router/note.ts 97.78% 80.95% 100% 97.78% 129-130, 462-463, 479-485
src/repository/noteVisits.repository.ts 100% 100% 100% 100%
src/repository/storage/postgres/orm/sequelize/noteVisits.ts 92% 75% 100% 92% 143-154, 170-171
src/tests/utils/database-helpers.ts 97.97% 94.73% 91.66% 97.97% 172-177
Generated in workflow #671

@e11sy e11sy changed the title Recent note list feat(recent-notes): save note visits on get/post note Apr 5, 2024
@e11sy e11sy changed the title feat(recent-notes): save note visits on get/post note feat(recent-notes): save and delete note visits on the appropriate routes Apr 5, 2024
src/presentation/http/router/note.ts Outdated Show resolved Hide resolved
src/presentation/http/router/note.ts Show resolved Hide resolved
src/presentation/http/router/note.ts Outdated Show resolved Hide resolved
src/presentation/http/router/note.ts Outdated Show resolved Hide resolved
src/presentation/http/router/note.ts Show resolved Hide resolved
e11sy added 2 commits April 6, 2024 17:20
- get rid of noteVisits service to avoid circular dependency via shared service
- moved noteVisitsService methods to noteService
src/presentation/http/router/note.ts Outdated Show resolved Hide resolved
@slaveeks
Copy link
Member

slaveeks commented Apr 6, 2024

As i remember, you faced with a trouble, that you need to create a unique index (note_id, user_id) for upsert method, i do not see it.

- left todo about event bus usage for saving and deleting noteVIsits
@e11sy e11sy merged commit a75c07e into main Apr 7, 2024
6 checks passed
@e11sy e11sy deleted the recent-note-list branch April 7, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Newly created note is not visible in recent notes list
5 participants