Skip to content

Commit

Permalink
Backend optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
joaovitoriasilva committed Jan 6, 2024
1 parent ad74fd7 commit 51ec61c
Show file tree
Hide file tree
Showing 41 changed files with 1,057 additions and 671 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ backend/*/__pycache__/
backend/*.pyc

# Logs
backend/logs/
backend/*.log
backend/logs/*.log
backend/*.log

# Frontend
frontend/img/users_img/*.*
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ JAEGER_PROTOCOL | http | Yes
JAEGER_HOST | jaeger | Yes
JAGGER_PORT | 4317 | Yes
STRAVA_DAYS_ACTIVITIES_ONLINK | 30 | Yes
API_ENDPOINT* | changeme | Yes

*API_ENDPOINT needs to be set if you want to enable Strava integration

Table bellow shows the obligatory environemnt variables for mariadb container. You should set them based on what was also set for backend container.

Expand Down
3 changes: 2 additions & 1 deletion backend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ JAEGER_ENABLED=true
JAEGER_PROTOCOL=http
JAEGER_HOST=jaeger
JAGGER_PORT=4317
STRAVA_DAYS_ACTIVITIES_ONLINK=30
STRAVA_DAYS_ACTIVITIES_ONLINK=30
API_ENDPOINT=changeme
20 changes: 18 additions & 2 deletions backend/controllers/activityController.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,15 @@ async def read_activities_useractivities_thisweek_distances(
distances = calculate_activity_distances(activity_records)

# Return the queried values using JSONResponse
return JSONResponse(content=distances)
#return JSONResponse(content=distances)

# Include metadata in the response
metadata = {"total_records": 1}

# Return the queried values using JSONResponse
return JSONResponse(
content={"metadata": metadata, "content": distances}
)
except JWTError:
# Return an error response if the user is not authenticated
return create_error_response("UNAUTHORIZED", "Unauthorized", 401)
Expand Down Expand Up @@ -479,7 +487,15 @@ async def read_activities_useractivities_thismonth_distances(
distances = calculate_activity_distances(activity_records)

# Return the queried values using JSONResponse
return JSONResponse(content=distances)
#return JSONResponse(content=distances)

# Include metadata in the response
metadata = {"total_records": 1}

# Return the queried values using JSONResponse
return JSONResponse(
content={"metadata": metadata, "content": distances}
)
except JWTError:
# Return an error response if the user is not authenticated
return create_error_response("UNAUTHORIZED", "Unauthorized", 401)
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/followerController.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"""
import logging
from fastapi import APIRouter, Depends, HTTPException
from fastapi import APIRouter, Depends
from fastapi.security import OAuth2PasswordBearer
from . import sessionController
from jose import JWTError
Expand Down
Loading

0 comments on commit 51ec61c

Please sign in to comment.