Refactor TodoService
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
TodoService became quite messy and I think we should refactor it.
Here are my suggestions (just couple of examples, I didn't really dive into it yet), it can be further discussed here or in a merge request.
What seems so messy
The service is quite long, a lot of 1-2 lines method. There is quite a lot of code duplication - we have eg.
-
new_issue+new_merge_requestwhich both just pass arguments tonew_issuable -
update_merge_request,update_issue->update_issuable -
close_issue,close_merge_request,merge_merge_request,merge_request_push->mark_pending_todos_as_done
Some other examples
- condition in method
reject_users_without_accesscould be simplified or removed if we split the service -
filter_todo_usersjust passes arguments toreject_users_without_access(and unique them) -
create_mention_todosmight be simplified as well
How we could improve it
- we have a
Todo::Destroymodule for destroying todos when a user looses permissions to the target - we could introduce
Todo::Createmodule for creating todos - create
Todo::Create::BaseServicewhere we would include methods likecreate_todos, getting & filtering mentioned users etc - create inherited classes as needed (eg.
IssuableService,NoteService)
Edited by 🤖 GitLab Bot 🤖