mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 06:46:00 +00:00
fix lint issues
This commit is contained in:
@@ -53,10 +53,7 @@ def upgrade() -> None:
|
||||
batch = rows[start : start + _BACKFILL_BATCH]
|
||||
bind.execute(
|
||||
update_stmt,
|
||||
[
|
||||
{"_id": row.id, "_key": compute_name_sort_key(row.name)}
|
||||
for row in batch
|
||||
],
|
||||
[{"_id": row.id, "_key": compute_name_sort_key(row.name)} for row in batch],
|
||||
)
|
||||
|
||||
op.create_index("idx_roms_name_sort_key", "roms", ["name_sort_key"])
|
||||
|
||||
@@ -8,7 +8,6 @@ from typing import Any
|
||||
from redis.exceptions import WatchError
|
||||
from sqlalchemy import (
|
||||
Integer,
|
||||
Row,
|
||||
String,
|
||||
Text,
|
||||
and_,
|
||||
@@ -419,11 +418,11 @@ class DBRomsHandler(DBBaseHandler):
|
||||
return query
|
||||
|
||||
if ROMM_DB_DRIVER in ("mariadb", "mysql"):
|
||||
match_clauses: list[Any] | None = []
|
||||
match_clauses: list[Any] = []
|
||||
for idx, term in enumerate(terms):
|
||||
boolean_query = self._build_fulltext_boolean_query(term)
|
||||
if boolean_query is None:
|
||||
match_clauses = None
|
||||
match_clauses = []
|
||||
break
|
||||
param = f"fulltext_search_{idx}"
|
||||
match_clauses.append(
|
||||
@@ -1158,7 +1157,7 @@ class DBRomsHandler(DBBaseHandler):
|
||||
.all()
|
||||
)
|
||||
|
||||
result = [[letter, int(position)] for letter, position in rows]
|
||||
result = [(letter, int(position)) for letter, position in rows]
|
||||
if redis_key is not None and version is not None:
|
||||
_store_versioned_cache(redis_key, version, result)
|
||||
return result
|
||||
|
||||
@@ -45,14 +45,15 @@ NAME_SORT_KEY_MAX_LENGTH = 500
|
||||
ARTICLE_PREFIX_RE = re.compile(r"^(the|a|an)\s+")
|
||||
DIGIT_RUN_RE = re.compile(r"\d+")
|
||||
|
||||
|
||||
def compute_name_sort_key(name: str | None) -> str:
|
||||
"""Precompute the natural-sort key stored in `Rom.name_sort_key`
|
||||
"""
|
||||
"""Precompute the natural-sort key stored in `Rom.name_sort_key`"""
|
||||
value = (name or "").lower()
|
||||
value = ARTICLE_PREFIX_RE.sub("", value).strip()
|
||||
value = DIGIT_RUN_RE.sub(lambda m: m.group(0).zfill(12), value)
|
||||
return value[:NAME_SORT_KEY_MAX_LENGTH]
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from models.assets import Save, Screenshot, State
|
||||
from models.collection import Collection
|
||||
|
||||
Reference in New Issue
Block a user