Skip to content

Commit

Permalink
run ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed May 19, 2024
1 parent e72a1d8 commit fbdf657
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
1 change: 1 addition & 0 deletions backend/endpoints/responses/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .firmware import FirmwareSchema


class PlatformSchema(BaseModel):
id: int
slug: str
Expand Down
22 changes: 6 additions & 16 deletions backend/handler/database/platforms_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import functools
from sqlalchemy import delete, func, or_, select
from sqlalchemy import delete, or_
from sqlalchemy.orm import Session, Query, joinedload

from decorators.database import begin_session
Expand All @@ -16,9 +16,7 @@ def wrapper(*args, **kwargs):
if session is None:
raise ValueError("session is required")

kwargs["query"] = session.query(Platform).options(
joinedload(Platform.roms)
)
kwargs["query"] = session.query(Platform).options(joinedload(Platform.roms))
return func(*args, **kwargs)

return wrapper
Expand All @@ -33,7 +31,7 @@ def add_platform(
session.merge(platform)
session.flush()

return query.filter(Platform.id == platform.id).first()
return query.filter(Platform.fs_slug == platform.fs_slug).first()

@begin_session
@with_query
Expand All @@ -43,21 +41,15 @@ def get_platforms(
return (
query.get(Platform, id)
if id
else (
session.scalars(query.order_by(Platform.name.asc()))
.unique()
.all()
)
else (session.scalars(query.order_by(Platform.name.asc())).unique().all())
)

@begin_session
@with_query
def get_platform_by_fs_slug(
self, fs_slug: str, query: Query = None, session: Session = None
) -> Platform | None:
return session.scalars(
query.filter_by(fs_slug=fs_slug).limit(1)
).first()
return session.scalars(query.filter_by(fs_slug=fs_slug).limit(1)).first()

@begin_session
def delete_platform(self, id: int, session: Session = None) -> int:
Expand All @@ -74,9 +66,7 @@ def delete_platform(self, id: int, session: Session = None) -> int:
)

@begin_session
def purge_platforms(
self, fs_platforms: list[str], session: Session = None
) -> int:
def purge_platforms(self, fs_platforms: list[str], session: Session = None) -> int:
return session.execute(
delete(Platform)
.where(or_(Platform.fs_slug.not_in(fs_platforms), Platform.slug.is_(None)))
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ api.interceptors.request.use((config) => {

// Cancel debounced networkQuiesced since a new request just came in
networkQuiesced.cancel();

// Set CSRF header for all requests
config.headers["x-csrftoken"] = cookie.get("csrftoken");
return config;
Expand Down

0 comments on commit fbdf657

Please sign in to comment.