Describe the bug
The backend has a file containing all of the dependencies for our endpoints, but for some reason we aren't using the dependencies.
dependencies.py looks good and could be used, but instead we are making the services in each endpoint unnecessarily. Examples below:
|
service = SnapshotService(db, epics) |
Expected behavior
All endpoints should make use of these dependencies instead of using the get_db dependency and creating the service themselves.
Steps to Reproduce
n/a
Possible solution (optional)
Old
|
async def create_tag_group(data: TagGroupCreate, db: AsyncSession = Depends(get_db)): |
|
"""Create a new tag group.""" |
|
service = TagService(db) |
|
try: |
|
group = await service.create_group(data) |
|
return success_response(group) |
|
except ValueError as e: |
|
raise APIException(409, str(e), 409) |
New
async def create_tag_group(data: TagGroupCreate, service: TagService = Depends(get_tag_service)):
"""Create a new tag group."""
try:
group = await service.create_group(data)
return success_response(group)
except ValueError as e:
raise APIException(409, str(e), 409)
My platform
No response
Additional context
No response
Describe the bug
The backend has a file containing all of the dependencies for our endpoints, but for some reason we aren't using the dependencies.
dependencies.py looks good and could be used, but instead we are making the services in each endpoint unnecessarily. Examples below:
react-squirrel-backend/app/api/v1/pvs.py
Line 22 in f47cd6e
react-squirrel-backend/app/api/v1/snapshots.py
Line 75 in f47cd6e
react-squirrel-backend/app/api/v1/tags.py
Line 72 in f47cd6e
Expected behavior
All endpoints should make use of these dependencies instead of using the
get_dbdependency and creating the service themselves.Steps to Reproduce
n/a
Possible solution (optional)
Old
react-squirrel-backend/app/api/v1/tags.py
Lines 38 to 45 in f47cd6e
New
My platform
No response
Additional context
No response