Repository navigation
Conversation
`GetGuiStatusUseCase` and `GetDatabaseStatusUseCase` are replaced by a `StatusService` (`getGuiStatus`, `getDatabaseStatus`), like the other resources read through services. The service receives the host and the port instead of the express request, and the controller no longer has the 501 branches, which could never happen as the use cases never returned null. The responses are unchanged. The use case tests are replaced by `StatusService` tests. The test of an unreachable database now restores the `database.ping` stub, instead of leaving it replaced for the following tests.
The seven tag use cases are replaced by a `TagService` (`getAll`, `getByIdentifier`, `create`, `update`, `remove`, `getLogs`) built on two small functions returning models, `getTag` and `getAllTags`, as it is done for run types and detectors. The services use `dataSource.transaction` like the other services. The responses of the tags endpoints are unchanged, including the 404 bodies of the endpoints that read or remove a tag, which the GUI and the tests rely on. The service takes the user id and the new values explicitly instead of a DTO with a session: `create` does not modify the values it receives anymore. The use case tests are replaced by `TagService` tests, and the tests that created or updated a tag through a use case now use the service.
graduta
force-pushed
the
refactor/O2B-1623/migrate-status-and-tags-use-cases-to-services
branch
from
October 22, 2026 10:11
517e12c to
43754e3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2277 +/- ##
==========================================
- Coverage 46.36% 46.16% -0.20%
==========================================
Files 1049 1042 -7
Lines 17351 17295 -56
Branches 3160 3157 -3
==========================================
- Hits 8044 7984 -60
- Misses 9307 9311 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a JIRA ticket
docs/backend-architecture.mdplans to replace theusecasesby controllers and services. This PR migrates two more resources that were still read through use cases, the ones found while documenting the HTTP API (O2B-1623):statusandtags(the run types ones were migrated in #2267).Notable changes for users:
/api/status/*and/api/tags/*are unchanged, including the 404 bodies of the tags endpoints (the GUI and the tests rely on them).Notable changes for developers:
StatusService(getGuiStatus,getDatabaseStatus) replacesGetGuiStatusUseCaseandGetDatabaseStatusUseCase. The service receives the host and the port instead of the express request. The501branches of the controller are removed, they could not happen as the use cases never returnednull.TagService(getAll,getByIdentifier,create,update,remove,getLogs) replaces the seven tag use cases. It is built on two small functions returning models,getTagandgetAllTags, like it is done for detectors, and usesdataSource.transactionlike the other services. The user id and the new values are given explicitly instead of a DTO with a session, andcreateno longer mutates the values it receives.lib/usecases/status,lib/usecases/tagand their tests are removed, replaced byStatusServiceandTagServicetests (the tests creating or updating a tag through a use case use the service). The unreachable-database test now restores itsdatabase.pingstub instead of leaving it replaced for the following tests.getAll,nullfor a missing tag, the errors messages ofcreateandupdate. The new and moved tests have not been run, only the CI does.Changes made to the database: