Spaces:
Sleeping
Sleeping
fix: add missing AppRole import in projects API and enable eager loading in invoice viewing service
Browse files
docs/devlogs/server/builderrors.txt
CHANGED
|
@@ -1,92 +1,50 @@
|
|
| 1 |
-
===== Application Startup at 2025-12-11 07:
|
| 2 |
|
| 3 |
INFO: Started server process [7]
|
| 4 |
INFO: Waiting for application startup.
|
| 5 |
-
INFO: 2025-12-11T07:
|
| 6 |
-
INFO: 2025-12-11T07:
|
| 7 |
-
INFO: 2025-12-11T07:
|
| 8 |
-
INFO: 2025-12-11T07:
|
| 9 |
-
INFO: 2025-12-11T07:
|
| 10 |
-
INFO: 2025-12-11T07:
|
| 11 |
-
INFO: 2025-12-11T07:
|
| 12 |
-
INFO: 2025-12-11T07:
|
| 13 |
-
INFO: 2025-12-11T07:
|
| 14 |
-
INFO: 2025-12-11T07:
|
| 15 |
-
INFO: 2025-12-11T07:
|
| 16 |
-
INFO: 2025-12-11T07:
|
| 17 |
-
INFO: 2025-12-11T07:
|
| 18 |
-
INFO: 2025-12-11T07:
|
| 19 |
-
INFO: 2025-12-11T07:
|
| 20 |
-
INFO: 2025-12-11T07:
|
| 21 |
-
INFO: 2025-12-11T07:
|
| 22 |
-
INFO: 2025-12-11T07:
|
| 23 |
-
INFO: 2025-12-11T07:
|
| 24 |
-
INFO: 2025-12-11T07:
|
| 25 |
-
INFO: 2025-12-11T07:
|
| 26 |
-
INFO: 2025-12-11T07:
|
| 27 |
-
INFO: 2025-12-11T07:
|
| 28 |
INFO: Application startup complete.
|
| 29 |
INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
|
| 30 |
-
INFO: 10.16.
|
| 31 |
-
INFO: 10.16.
|
| 32 |
-
INFO: 10.16.37.13:
|
| 33 |
-
INFO: 10.16.
|
| 34 |
-
INFO: 10.16.13.79:
|
| 35 |
-
INFO: 10.16.
|
| 36 |
-
INFO:
|
| 37 |
-
INFO:
|
| 38 |
-
INFO: 10.16.37.13:
|
| 39 |
-
INFO:
|
| 40 |
-
INFO:
|
| 41 |
-
INFO: 10.16.13.79:
|
| 42 |
-
INFO:
|
| 43 |
-
INFO:
|
| 44 |
-
INFO: 10.16.37.13:
|
| 45 |
-
INFO: 10.16.37.13:
|
| 46 |
-
INFO: 10.16.37.13:
|
| 47 |
-
INFO: 10.16.
|
| 48 |
-
INFO: 10.16.37.13:6790 - "GET /health HTTP/1.1" 200 OK
|
| 49 |
-
INFO: 10.16.37.13:24737 - "GET /health HTTP/1.1" 200 OK
|
| 50 |
-
INFO: 2025-12-11T07:37:10 - app.core.supabase_auth: User signed in successfully: nadina73@nembors.com
|
| 51 |
-
INFO: 2025-12-11T07:37:11 - app.services.audit_service: Audit log created: login on auth by nadina73@nembors.com
|
| 52 |
-
INFO: 2025-12-11T07:37:11 - app.api.v1.auth: User logged in successfully: nadina73@nembors.com
|
| 53 |
-
INFO: 10.16.37.13:40121 - "POST /api/v1/auth/login HTTP/1.1" 200 OK
|
| 54 |
-
INFO: 2025-12-11T07:37:11 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 55 |
-
INFO: 2025-12-11T07:37:11 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 56 |
-
INFO: 10.16.13.79:61613 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 57 |
-
INFO: 2025-12-11T07:37:12 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 58 |
-
INFO: 2025-12-11T07:37:12 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 59 |
-
INFO: 10.16.37.13:40121 - "GET /api/v1/auth/me/preferences HTTP/1.1" 200 OK
|
| 60 |
-
INFO: 2025-12-11T07:37:12 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 61 |
-
INFO: 2025-12-11T07:37:12 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 62 |
-
INFO: 10.16.13.79:61613 - "GET /api/v1/auth/me/preferences/available-apps HTTP/1.1" 200 OK
|
| 63 |
-
INFO: 2025-12-11T07:37:14 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 64 |
-
INFO: 2025-12-11T07:37:14 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 65 |
-
INFO: 10.16.13.79:61613 - "GET /api/v1/analytics/user/overview HTTP/1.1" 200 OK
|
| 66 |
-
INFO: 2025-12-11T07:37:15 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 67 |
-
INFO: 2025-12-11T07:37:15 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 68 |
-
INFO: 2025-12-11T07:37:15 - app.services.project_service: Listed 1 projects (total: 1) for user c5cf92be-4172-4fe2-af5c-f05d83b3a938
|
| 69 |
-
INFO: 10.16.37.13:40121 - "GET /api/v1/projects?page=1&per_page=100 HTTP/1.1" 200 OK
|
| 70 |
-
INFO: 2025-12-11T07:37:18 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 71 |
-
INFO: 2025-12-11T07:37:18 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 72 |
-
INFO: 2025-12-11T07:37:18 - app.services.audit_service: Audit log created: update on user_preferences by nadina73@nembors.com
|
| 73 |
-
INFO: 2025-12-11T07:37:18 - app.api.v1.auth: Preferences updated for user: nadina73@nembors.com
|
| 74 |
-
INFO: 10.16.13.79:24575 - "PUT /api/v1/auth/me/preferences HTTP/1.1" 200 OK
|
| 75 |
-
INFO: 2025-12-11T07:37:19 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 76 |
-
INFO: 2025-12-11T07:37:19 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 77 |
-
INFO: 10.16.37.13:22676 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 78 |
-
INFO: 2025-12-11T07:37:19 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 79 |
-
INFO: 2025-12-11T07:37:19 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 80 |
-
INFO: 2025-12-11T07:37:19 - app.services.dashboard_service: Dashboard cache MISS for project 0ade6bd1-e492-4e25-b681-59f42058d29a, user c5cf92be-4172-4fe2-af5c-f05d83b3a938 - building fresh data
|
| 81 |
-
INFO: 2025-12-11T07:37:19 - app.services.dashboard_service: Built and cached dashboard for project 0ade6bd1-e492-4e25-b681-59f42058d29a
|
| 82 |
-
INFO: 10.16.13.79:24575 - "GET /api/v1/projects/0ade6bd1-e492-4e25-b681-59f42058d29a/dashboard HTTP/1.1" 200 OK
|
| 83 |
-
INFO: 10.16.13.79:24575 - "GET /api/v1/notifications?project_id=0ade6bd1-e492-4e25-b681-59f42058d29a&page_size=50&is_read=false HTTP/1.1" 200 OK
|
| 84 |
-
INFO: 10.16.37.13:22676 - "GET /api/v1/tickets/stats?project_id=0ade6bd1-e492-4e25-b681-59f42058d29a HTTP/1.1" 200 OK
|
| 85 |
-
INFO: 10.16.37.13:22676 - "GET /api/v1/contractor-invoices/stats?project_id=0ade6bd1-e492-4e25-b681-59f42058d29a HTTP/1.1" 200 OK
|
| 86 |
-
INFO: 10.16.13.79:24575 - "GET /api/v1/contractor-invoices?project_id=0ade6bd1-e492-4e25-b681-59f42058d29a HTTP/1.1" 200 OK
|
| 87 |
-
INFO: 10.16.37.13:22676 - "GET /api/v1/contractor-invoices/81c96213-485f-4170-92a0-23c08332923b HTTP/1.1" 200 OK
|
| 88 |
-
INFO: 10.16.37.13:31765 - "GET /api/v1/tickets/2de41ce7-dff1-4151-9710-87958d18b5c4/detail HTTP/1.1" 200 OK
|
| 89 |
-
INFO: 10.16.13.79:34462 - "GET /api/v1/projects/0ade6bd1-e492-4e25-b681-59f42058d29a/regions/4cd27765-5720-4cc0-872e-bf0da3cd1898 HTTP/1.1" 500 Internal Server Error
|
| 90 |
ERROR: Exception in ASGI application
|
| 91 |
Traceback (most recent call last):
|
| 92 |
File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
|
|
@@ -128,8 +86,7 @@ Traceback (most recent call last):
|
|
| 128 |
File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
|
| 129 |
return await dependant.call(**values)
|
| 130 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 131 |
-
File "/app/src/app/api/v1/projects.py", line
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
INFO: 10.16.37.13:13519 - "GET /health HTTP/1.1" 200 OK
|
|
|
|
| 1 |
+
===== Application Startup at 2025-12-11 07:43:43 =====
|
| 2 |
|
| 3 |
INFO: Started server process [7]
|
| 4 |
INFO: Waiting for application startup.
|
| 5 |
+
INFO: 2025-12-11T07:43:56 - app.main: ============================================================
|
| 6 |
+
INFO: 2025-12-11T07:43:56 - app.main: π SwiftOps API v1.0.0 | PRODUCTION
|
| 7 |
+
INFO: 2025-12-11T07:43:56 - app.main: π Dashboard: Enabled
|
| 8 |
+
INFO: 2025-12-11T07:43:56 - app.main: ============================================================
|
| 9 |
+
INFO: 2025-12-11T07:43:56 - app.main: π¦ Database:
|
| 10 |
+
INFO: 2025-12-11T07:43:56 - app.main: β Connected | 47 tables | 6 users
|
| 11 |
+
INFO: 2025-12-11T07:43:56 - app.main: πΎ Cache & Sessions:
|
| 12 |
+
INFO: 2025-12-11T07:43:58 - app.services.otp_service: β
OTP Service initialized with Redis storage
|
| 13 |
+
INFO: 2025-12-11T07:43:58 - app.main: β Redis: Connected
|
| 14 |
+
INFO: 2025-12-11T07:43:58 - app.main: π External Services:
|
| 15 |
+
INFO: 2025-12-11T07:43:59 - app.main: β Cloudinary: Connected
|
| 16 |
+
INFO: 2025-12-11T07:43:59 - app.main: β Resend: Configured
|
| 17 |
+
INFO: 2025-12-11T07:43:59 - app.main: β WASender: Disconnected
|
| 18 |
+
INFO: 2025-12-11T07:43:59 - app.main: β Supabase: Connected | 6 buckets
|
| 19 |
+
INFO: 2025-12-11T07:43:59 - app.main: β° Scheduler:
|
| 20 |
+
INFO: 2025-12-11T07:43:59 - apscheduler.scheduler: Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
| 21 |
+
INFO: 2025-12-11T07:43:59 - apscheduler.scheduler: Added job "Daily Field Agent Reconciliation" to job store "default"
|
| 22 |
+
INFO: 2025-12-11T07:43:59 - apscheduler.scheduler: Scheduler started
|
| 23 |
+
INFO: 2025-12-11T07:43:59 - app.tasks.scheduler: Reconciliation scheduler started (runs at 10 PM Africa/Nairobi)
|
| 24 |
+
INFO: 2025-12-11T07:43:59 - app.main: β Daily reconciliation scheduler started (runs at midnight)
|
| 25 |
+
INFO: 2025-12-11T07:43:59 - app.main: ============================================================
|
| 26 |
+
INFO: 2025-12-11T07:43:59 - app.main: β
Startup complete | Ready to serve requests
|
| 27 |
+
INFO: 2025-12-11T07:43:59 - app.main: ============================================================
|
| 28 |
INFO: Application startup complete.
|
| 29 |
INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
|
| 30 |
+
INFO: 10.16.13.79:14670 - "GET /health HTTP/1.1" 200 OK
|
| 31 |
+
INFO: 10.16.37.13:65483 - "GET /health HTTP/1.1" 200 OK
|
| 32 |
+
INFO: 10.16.37.13:54114 - "GET /health HTTP/1.1" 200 OK
|
| 33 |
+
INFO: 10.16.37.13:54114 - "GET /api/v1/invoices/view?token=Vuds_hyGrwV7qRNL56QdPD_1zQNE3_NDvtdatIe2MiM HTTP/1.1" 200 OK
|
| 34 |
+
INFO: 10.16.13.79:54645 - "GET /health HTTP/1.1" 200 OK
|
| 35 |
+
INFO: 10.16.13.79:50461 - "GET /health HTTP/1.1" 200 OK
|
| 36 |
+
INFO: 2025-12-11T07:45:37 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 37 |
+
INFO: 2025-12-11T07:45:37 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 38 |
+
INFO: 10.16.37.13:46918 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 39 |
+
INFO: 2025-12-11T07:45:37 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 40 |
+
INFO: 2025-12-11T07:45:37 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 41 |
+
INFO: 10.16.13.79:50461 - "GET /api/v1/auth/me/preferences HTTP/1.1" 200 OK
|
| 42 |
+
INFO: 2025-12-11T07:45:37 - app.api.deps: Checking active user: c5cf92be-4172-4fe2-af5c-f05d83b3a938, is_active: True, type: <class 'bool'>
|
| 43 |
+
INFO: 2025-12-11T07:45:37 - app.api.deps: User c5cf92be-4172-4fe2-af5c-f05d83b3a938 is active - proceeding
|
| 44 |
+
INFO: 10.16.37.13:46918 - "GET /api/v1/auth/me/preferences/available-apps HTTP/1.1" 200 OK
|
| 45 |
+
INFO: 10.16.37.13:46918 - "GET /api/v1/contractor-invoices/81c96213-485f-4170-92a0-23c08332923b HTTP/1.1" 200 OK
|
| 46 |
+
INFO: 10.16.37.13:39893 - "GET /api/v1/tickets/2de41ce7-dff1-4151-9710-87958d18b5c4/detail HTTP/1.1" 200 OK
|
| 47 |
+
INFO: 10.16.13.79:58923 - "GET /api/v1/projects/0ade6bd1-e492-4e25-b681-59f42058d29a/regions/4cd27765-5720-4cc0-872e-bf0da3cd1898 HTTP/1.1" 500 Internal Server Error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
ERROR: Exception in ASGI application
|
| 49 |
Traceback (most recent call last):
|
| 50 |
File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
|
|
|
|
| 86 |
File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
|
| 87 |
return await dependant.call(**values)
|
| 88 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 89 |
+
File "/app/src/app/api/v1/projects.py", line 1756, in get_project_region
|
| 90 |
+
if current_user.role != AppRole.PLATFORM_ADMIN.value:
|
| 91 |
+
^^^^^^^
|
| 92 |
+
NameError: name 'AppRole' is not defined
|
|
|
src/app/api/v1/projects.py
CHANGED
|
@@ -15,6 +15,7 @@ from app.models.user import User
|
|
| 15 |
from app.models.project import Project
|
| 16 |
from app.models.project_team import ProjectTeam
|
| 17 |
from app.models.notification import Notification
|
|
|
|
| 18 |
from app.schemas.project import (
|
| 19 |
ProjectCreate, ProjectUpdate, ProjectResponse, ProjectListResponse,
|
| 20 |
ProjectStatusUpdate, ProjectClose, ProjectSetup, ProjectSetupResponse,
|
|
|
|
| 15 |
from app.models.project import Project
|
| 16 |
from app.models.project_team import ProjectTeam
|
| 17 |
from app.models.notification import Notification
|
| 18 |
+
from app.models.enums import AppRole
|
| 19 |
from app.schemas.project import (
|
| 20 |
ProjectCreate, ProjectUpdate, ProjectResponse, ProjectListResponse,
|
| 21 |
ProjectStatusUpdate, ProjectClose, ProjectSetup, ProjectSetupResponse,
|
src/app/services/invoice_viewing_service.py
CHANGED
|
@@ -41,8 +41,13 @@ class InvoiceViewingService:
|
|
| 41 |
- Ticket details with images
|
| 42 |
- Image URLs (Cloudinary public URLs)
|
| 43 |
"""
|
| 44 |
-
# Find invoice by token
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
ContractorInvoice.viewing_token == token,
|
| 47 |
ContractorInvoice.deleted_at.is_(None)
|
| 48 |
).first()
|
|
|
|
| 41 |
- Ticket details with images
|
| 42 |
- Image URLs (Cloudinary public URLs)
|
| 43 |
"""
|
| 44 |
+
# Find invoice by token with eager loading of relationships
|
| 45 |
+
from sqlalchemy.orm import joinedload
|
| 46 |
+
invoice = db.query(ContractorInvoice).options(
|
| 47 |
+
joinedload(ContractorInvoice.contractor),
|
| 48 |
+
joinedload(ContractorInvoice.client),
|
| 49 |
+
joinedload(ContractorInvoice.project)
|
| 50 |
+
).filter(
|
| 51 |
ContractorInvoice.viewing_token == token,
|
| 52 |
ContractorInvoice.deleted_at.is_(None)
|
| 53 |
).first()
|