Skip to content

Commit

Permalink
refactor endpoints for improved readability and maintenance (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Aug 19, 2024
1 parent 294322e commit 48a2a17
Show file tree
Hide file tree
Showing 16 changed files with 792 additions and 508 deletions.
4 changes: 2 additions & 2 deletions offsets_db_api/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from fastapi import Request, Response
from fastapi_cache import FastAPICache

from .logging import get_logger
from .query_helpers import _convert_query_params_to_dict
from offsets_db_api.log import get_logger
from offsets_db_api.query_helpers import _convert_query_params_to_dict

logger = get_logger()

Expand Down
2 changes: 1 addition & 1 deletion offsets_db_api/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import Session, create_engine

from .settings import get_settings
from offsets_db_api.settings import get_settings


def get_engine(*, database_url: str):
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions offsets_db_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer

from .app_metadata import metadata
from .cache import clear_cache, request_key_builder, watch_dog_dir, watch_dog_file
from .logging import get_logger
from .routers import charts, clips, credits, files, health, projects
from offsets_db_api.app_metadata import metadata
from offsets_db_api.cache import clear_cache, request_key_builder, watch_dog_dir, watch_dog_file
from offsets_db_api.log import get_logger
from offsets_db_api.routers import charts, clips, credits, files, health, projects

logger = get_logger()

Expand Down
11 changes: 8 additions & 3 deletions offsets_db_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.dialects import postgresql
from sqlmodel import BigInteger, Column, Field, Relationship, SQLModel, String

from .schemas import FileCategory, FileStatus, Pagination
from offsets_db_api.schemas import FileCategory, FileStatus, Pagination


class File(SQLModel, table=True):
Expand Down Expand Up @@ -140,12 +140,12 @@ class CreditWithCategory(CreditBase):

class PaginatedProjects(pydantic.BaseModel):
pagination: Pagination
data: list[ProjectWithClips]
data: list[ProjectWithClips] | list[dict[str, typing.Any]]


class PaginatedCredits(pydantic.BaseModel):
pagination: Pagination
data: list[CreditWithCategory]
data: list[CreditWithCategory] | list[dict[str, typing.Any]]


class BinnedValues(pydantic.BaseModel):
Expand Down Expand Up @@ -207,3 +207,8 @@ class PaginatedBinnedCreditTotals(pydantic.BaseModel):
class PaginatedClips(pydantic.BaseModel):
pagination: Pagination
data: list[ClipwithProjects] | list[dict[str, typing.Any]]


class PaginatedFiles(pydantic.BaseModel):
pagination: Pagination
data: list[File] | list[dict[str, typing.Any]]
4 changes: 2 additions & 2 deletions offsets_db_api/query_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from sqlalchemy.orm import Query
from sqlmodel import and_, asc, desc, distinct, func, nullslast, or_, select

from .logging import get_logger
from .models import Clip, ClipProject, Credit, Project
from offsets_db_api.log import get_logger
from offsets_db_api.models import Clip, ClipProject, Credit, Project

logger = get_logger()

Expand Down
Loading

0 comments on commit 48a2a17

Please sign in to comment.