Spaces:
Running
Running
analytics page fix
Browse files
frontend/src/pages/AnalyticsPage/AnalyticsPage.tsx
CHANGED
|
@@ -189,9 +189,14 @@ export default function AnalyticsPage() {
|
|
| 189 |
}, []);
|
| 190 |
|
| 191 |
useEffect(() => {
|
| 192 |
-
fetchAnalytics();
|
| 193 |
fetchLookupData();
|
| 194 |
-
}, [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
const getSourceLabel = useCallback((code: string) => {
|
| 197 |
const source = sourcesLookup.find(s => s.s_code === code);
|
|
|
|
| 189 |
}, []);
|
| 190 |
|
| 191 |
useEffect(() => {
|
|
|
|
| 192 |
fetchLookupData();
|
| 193 |
+
}, []);
|
| 194 |
+
|
| 195 |
+
useEffect(() => {
|
| 196 |
+
if (sourcesLookup.length > 0 && typesLookup.length > 0 && regionsLookup.length > 0) {
|
| 197 |
+
fetchAnalytics();
|
| 198 |
+
}
|
| 199 |
+
}, [sourcesLookup, typesLookup, regionsLookup, fetchAnalytics]);
|
| 200 |
|
| 201 |
const getSourceLabel = useCallback((code: string) => {
|
| 202 |
const source = sourcesLookup.find(s => s.s_code === code);
|
py_backend/app/routers/images.py
CHANGED
|
@@ -8,6 +8,7 @@ from ..models import Images, image_countries
|
|
| 8 |
from ..images import CreateImageFromUrlIn, CreateImageFromUrlOut
|
| 9 |
from .. import storage
|
| 10 |
from ..storage import upload_bytes, get_object_url
|
|
|
|
| 11 |
|
| 12 |
router = APIRouter()
|
| 13 |
|
|
|
|
| 8 |
from ..images import CreateImageFromUrlIn, CreateImageFromUrlOut
|
| 9 |
from .. import storage
|
| 10 |
from ..storage import upload_bytes, get_object_url
|
| 11 |
+
from ..config import settings
|
| 12 |
|
| 13 |
router = APIRouter()
|
| 14 |
|
py_backend/app/storage.py
CHANGED
|
@@ -6,6 +6,7 @@ from typing import BinaryIO, Optional
|
|
| 6 |
|
| 7 |
from .config import settings
|
| 8 |
|
|
|
|
| 9 |
if settings.STORAGE_PROVIDER != "local":
|
| 10 |
import boto3
|
| 11 |
import botocore
|
|
@@ -17,6 +18,19 @@ if settings.STORAGE_PROVIDER != "local":
|
|
| 17 |
aws_secret_access_key=settings.S3_SECRET_KEY,
|
| 18 |
region_name=getattr(settings, "S3_REGION", None),
|
| 19 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Optional settings you can add to your config:
|
| 22 |
# - S3_PUBLIC_URL_BASE: str | None (e.g. "https://cdn.example.com" or bucket website endpoint)
|
|
|
|
| 6 |
|
| 7 |
from .config import settings
|
| 8 |
|
| 9 |
+
# Initialize s3 client based on storage provider
|
| 10 |
if settings.STORAGE_PROVIDER != "local":
|
| 11 |
import boto3
|
| 12 |
import botocore
|
|
|
|
| 18 |
aws_secret_access_key=settings.S3_SECRET_KEY,
|
| 19 |
region_name=getattr(settings, "S3_REGION", None),
|
| 20 |
)
|
| 21 |
+
else:
|
| 22 |
+
# Create a dummy s3 object for local storage to avoid AttributeError
|
| 23 |
+
class DummyS3Client:
|
| 24 |
+
def __init__(self):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
def get_object(self, **kwargs):
|
| 28 |
+
raise RuntimeError("S3 client not available in local storage mode")
|
| 29 |
+
|
| 30 |
+
def generate_presigned_url(self, **kwargs):
|
| 31 |
+
raise RuntimeError("S3 client not available in local storage mode")
|
| 32 |
+
|
| 33 |
+
s3 = DummyS3Client()
|
| 34 |
|
| 35 |
# Optional settings you can add to your config:
|
| 36 |
# - S3_PUBLIC_URL_BASE: str | None (e.g. "https://cdn.example.com" or bucket website endpoint)
|