Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ jobs:
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: 🏷️ Read package version
run: echo "PACKAGE_VERSION=$(head -n 1 lncrawl/VERSION)" >> $GITHUB_ENV

- name: 🏗️ Build and Push Image
uses: docker/build-push-action@v5
with:
Expand All @@ -183,6 +186,7 @@ jobs:
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${GITHUB_REF##*/}
ghcr.io/${{ github.repository }}:${{ env.PACKAGE_VERSION }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
Expand Down
3 changes: 2 additions & 1 deletion lncrawl/bots/server/models/novel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Dict, List, Optional

from pydantic import computed_field, BaseModel
from sqlalchemy.sql.expression import column
from sqlmodel import JSON, Column, Field, Index, func

from ._base import BaseTable
Expand All @@ -24,7 +25,7 @@ class Novel(BaseTable, table=True):
extra: Dict[str, Any] = Field(default={}, sa_column=Column(JSON), description="Extra field")

__table_args__ = (
Index("idx_novel_title_lower", func.lower(title)),
Index("idx_novel_title_lower", func.lower(column("title"))),
)


Expand Down
5 changes: 4 additions & 1 deletion lncrawl/bots/server/services/novels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from ..models.user import User, UserRole


NOVEL_TITLE_COLUMN = Novel.__table__.c.title


class NovelService:
def __init__(self, ctx: ServerContext) -> None:
self._ctx = ctx
Expand All @@ -34,7 +37,7 @@ def list(

if search:
q = f"%{search.lower()}%"
conditions.append(func.lower(Novel.title).like(q))
conditions.append(func.lower(NOVEL_TITLE_COLUMN).like(q))

if conditions:
cnd = and_(*conditions)
Expand Down
14 changes: 10 additions & 4 deletions lncrawl/bots/server/services/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
UpdateRequest, User, UserRole, UserTier,
VerifiedEmail)

USER_TABLE = User.__table__
USER_NAME_COLUMN = USER_TABLE.c.name
USER_EMAIL_COLUMN = USER_TABLE.c.email
USER_ROLE_COLUMN = USER_TABLE.c.role
USER_TIER_COLUMN = USER_TABLE.c.tier

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -113,10 +119,10 @@ def list(
q = f'%{search.lower()}%'
conditions.append(
or_(
func.lower(User.name).like(q),
func.lower(User.email).like(q),
func.lower(User.role).like(q),
func.lower(User.tier).like(q),
func.lower(USER_NAME_COLUMN).like(q),
func.lower(USER_EMAIL_COLUMN).like(q),
func.lower(USER_ROLE_COLUMN).like(q),
func.lower(USER_TIER_COLUMN).like(q),
)
)

Expand Down