refactor: replace local _get_data_dir() with shared app.utils.get_data_dir()
Replace copy-pasted _get_data_dir() functions in catalog.py and upload.py with import from app.utils.get_data_dir(). sync.py and data.py already use the shared utility.
This commit is contained in:
parent
53a9e838f9
commit
c56511f69f
2 changed files with 2 additions and 12 deletions
|
|
@ -1,25 +1,20 @@
|
||||||
"""Catalog endpoints — table profiles, metrics."""
|
"""Catalog endpoints — table profiles, metrics."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
import duckdb
|
import duckdb
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from app.auth.dependencies import get_current_user, _get_db
|
from app.auth.dependencies import get_current_user, _get_db
|
||||||
|
from app.utils import get_data_dir as _get_data_dir
|
||||||
from src.repositories.profiles import ProfileRepository
|
from src.repositories.profiles import ProfileRepository
|
||||||
from src.rbac import can_access_table
|
from src.rbac import can_access_table
|
||||||
|
|
||||||
router = APIRouter(prefix="/api/catalog", tags=["catalog"])
|
router = APIRouter(prefix="/api/catalog", tags=["catalog"])
|
||||||
|
|
||||||
|
|
||||||
def _get_data_dir() -> Path:
|
|
||||||
return Path(os.environ.get("DATA_DIR", "./data"))
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/profile/{table_name}")
|
@router.get("/profile/{table_name}")
|
||||||
async def get_table_profile(
|
async def get_table_profile(
|
||||||
table_name: str,
|
table_name: str,
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,18 @@
|
||||||
"""Upload endpoints — sessions, artifacts, CLAUDE.local.md."""
|
"""Upload endpoints — sessions, artifacts, CLAUDE.local.md."""
|
||||||
|
|
||||||
import os
|
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
|
||||||
from pathlib import Path as _Path
|
from pathlib import Path as _Path
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File
|
from fastapi import APIRouter, Depends, HTTPException, UploadFile, File
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from app.auth.dependencies import get_current_user
|
from app.auth.dependencies import get_current_user
|
||||||
|
from app.utils import get_data_dir as _get_data_dir
|
||||||
|
|
||||||
router = APIRouter(prefix="/api/upload", tags=["upload"])
|
router = APIRouter(prefix="/api/upload", tags=["upload"])
|
||||||
|
|
||||||
|
|
||||||
def _get_data_dir() -> Path:
|
|
||||||
return Path(os.environ.get("DATA_DIR", "./data"))
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/sessions")
|
@router.post("/sessions")
|
||||||
async def upload_session(
|
async def upload_session(
|
||||||
file: UploadFile = File(...),
|
file: UploadFile = File(...),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue