Skip to content

Commit

Permalink
Merge pull request #40 from wednesday-solutions/fix/minor-changes
Browse files Browse the repository at this point in the history
fix - Minor changes of api endpoint + readme file updated
  • Loading branch information
himanshu-wedensday authored Mar 22, 2024
2 parents 9788299 + d391a9f commit cf64071
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ This repository provides a template for creating and deploying a FastAPI project
- Formatting using black
- Code quality analysis using SonarQube
- Application monitoring using Signoz
- Feature flagging added - User can enabled/disabled
- Feature flagging added - User can enable/disable features
- Database Monitoring using percona
- Loadtests using locust

### Getting Started

#### Requirements:
- Python 3.11
- Python 3
- Docker
- mysql

Expand Down Expand Up @@ -238,10 +238,9 @@ By following these steps, you'll successfully configure Percona to monitor your
#### Dashboard Links
- Percona: https://localhost:443
- flower: http://localhost:5556
- server: http://localhost:8000
- locust: http://localhost:8089
- server-healthcheck: http://localhost:8000/home
- Flower: http://localhost:5556
- Locust UI: http://localhost:8089
- Swagger UI: http://localhost:8000
#### Useful scripts
Expand Down
5 changes: 4 additions & 1 deletion app/daos/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

async def get_user(user_id: int, db_session: Session):
try:
if not user_id:
raise NoUserFoundException(messages["NO_USER_ID_PROVIDED"])

cache_key = f"user_{user_id}"
cached_user, _ = await CacheUtils.retrieve_cache(cache_key)
if cached_user:
Expand Down Expand Up @@ -119,7 +122,7 @@ def login(data: Login, db_session: Session):
)

if not user_details:
raise InvalidCredentialsException(messages["INVALID_CREDENTIALS"])
raise InvalidCredentialsException(messages["NO_USERS_FOUND_IN_DB"])

if not check_password_hash(user_details.password, user_data["password"]):
raise InvalidCredentialsException(messages["INVALID_CREDENTIALS"])
Expand Down
2 changes: 1 addition & 1 deletion app/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .users import user_router

api_router = APIRouter()
api_router.include_router(user_router, prefix="/user")
api_router.include_router(user_router, prefix="/users")
api_router.include_router(home_router, prefix="/home")
api_router.include_router(celery_sample_router, prefix="/celery-sample")
api_router.include_router(cache_sample_router, prefix="/cache-sample")
Expand Down
3 changes: 2 additions & 1 deletion app/routes/users/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from fastapi import APIRouter
from fastapi import Depends
from fastapi import Path
from fastapi.security import HTTPBearer
from fastapi_pagination import Page
from sqlalchemy.orm import Session
Expand Down Expand Up @@ -38,7 +39,7 @@ def login(payload: Login, db: Session = Depends(create_local_session)):
@user_router.get("/{user_id}", tags=["Users"], dependencies=[Depends(get_current_user)], response_model=UserOutResponse)
async def profile(
token: Annotated[str, Depends(httpBearerScheme)],
user_id,
user_id: int = Path(..., title="ID of the user"),
db: Session = Depends(create_local_session),
):
response = await get_user_dao(user_id, db_session=db)
Expand Down

1 comment on commit cf64071

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   app.py372824%12–67
app/config
   __init__.py3167%6
   base.py37295%53–54
   celery_config.py17170%1–27
   celery_utils.py21210%1–30
   redis_config.py5260%8–9
app/constants
   jwt_utils.py161131%11–23
app/daos
   home.py10550%11–18
   users.py726411%12–136
app/middlewares
   cache_middleware.py51510%1–67
   rate_limiter_middleware.py25250%1–35
   request_id_injection.py17170%1–25
app/models
   __init__.py330%1–5
   users.py27270%1–38
app/routes
   __init__.py12120%1–15
app/routes/cache_router
   __init__.py330%1–5
   cache_samples.py12120%1–18
app/routes/celery_router
   __init__.py330%1–5
   celery_samples.py12120%1–17
app/routes/home
   __init__.py330%1–5
   home.py33330%1–45
app/routes/users
   __init__.py330%1–5
   users.py38380%1–57
app/schemas/users
   users_request.py42420%1–73
   users_response.py10100%1–14
app/sessions
   db.py53530%1–82
app/tests
   test_basic.py201525%10–34
   test_daos_home.py231057%15–22, 28–37, 41
   test_daos_users.py1109514%19–208
app/utils
   exception_handler.py19190%1–36
   redis_utils.py440%1–7
   slack_notification_utils.py14140%1–32
   user_utils.py25250%1–36
app/wrappers
   cache_wrappers.py26260%1–32
TOTAL82370614% 

Tests Skipped Failures Errors Time
2 0 💤 0 ❌ 2 🔥 0.859s ⏱️

Please sign in to comment.