diff --git a/amt/clients/clients.py b/amt/clients/clients.py index b650489a9..bd9f2413f 100644 --- a/amt/clients/clients.py +++ b/amt/clients/clients.py @@ -24,14 +24,12 @@ def get_content(self, url: str) -> bytes: """ This method should implement getting the content of an instrument from given URL. """ - ... @abstractmethod def list_content(self, url: str = "") -> RepositoryContent: """ This method should implement getting list of instruments from given URL. """ - ... def _get(self, url: str) -> httpx.Response: """ diff --git a/amt/locale/base.pot b/amt/locale/base.pot index cb74c929c..ee6fad9f1 100644 --- a/amt/locale/base.pot +++ b/amt/locale/base.pot @@ -8,14 +8,14 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-07-26 13:53+0200\n" +"POT-Creation-Date: 2024-08-15 15:18+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.15.0\n" +"Generated-By: Babel 2.16.0\n" #: amt/site/templates/header.html.j2:4 msgid "Algorithm Management Toolkit" @@ -66,6 +66,10 @@ msgstr "" msgid "Unknown" msgstr "" +#: amt/site/templates/projects/index.html.j2:11 +msgid "Find projects..." +msgstr "" + #: amt/site/templates/projects/new.html.j2:4 msgid "New Project" msgstr "" diff --git a/amt/locale/en_US/LC_MESSAGES/messages.mo b/amt/locale/en_US/LC_MESSAGES/messages.mo index 2e7f529c0..42de0cd24 100644 Binary files a/amt/locale/en_US/LC_MESSAGES/messages.mo and b/amt/locale/en_US/LC_MESSAGES/messages.mo differ diff --git a/amt/locale/en_US/LC_MESSAGES/messages.po b/amt/locale/en_US/LC_MESSAGES/messages.po index 57d4a1eb4..ba997f027 100644 --- a/amt/locale/en_US/LC_MESSAGES/messages.po +++ b/amt/locale/en_US/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-07-26 13:53+0200\n" +"POT-Creation-Date: 2024-08-15 15:18+0200\n" "PO-Revision-Date: 2024-07-25 21:01+0200\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.15.0\n" +"Generated-By: Babel 2.16.0\n" #: amt/site/templates/header.html.j2:4 msgid "Algorithm Management Toolkit" @@ -67,6 +67,10 @@ msgstr "" msgid "Unknown" msgstr "" +#: amt/site/templates/projects/index.html.j2:11 +msgid "Find project..." +msgstr "" + #: amt/site/templates/projects/new.html.j2:4 msgid "New Project" msgstr "" diff --git a/amt/locale/nl_FY/LC_MESSAGES/messages.mo b/amt/locale/nl_FY/LC_MESSAGES/messages.mo index de50608be..f222f55c0 100644 Binary files a/amt/locale/nl_FY/LC_MESSAGES/messages.mo and b/amt/locale/nl_FY/LC_MESSAGES/messages.mo differ diff --git a/amt/locale/nl_FY/LC_MESSAGES/messages.po b/amt/locale/nl_FY/LC_MESSAGES/messages.po index 0c895bae2..ac1c5364f 100644 --- a/amt/locale/nl_FY/LC_MESSAGES/messages.po +++ b/amt/locale/nl_FY/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-07-26 13:53+0200\n" +"POT-Creation-Date: 2024-08-15 15:18+0200\n" "PO-Revision-Date: 2024-07-25 21:01+0200\n" "Last-Translator: FULL NAME \n" "Language: nl_FY\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.15.0\n" +"Generated-By: Babel 2.16.0\n" #: amt/site/templates/header.html.j2:4 msgid "Algorithm Management Toolkit" @@ -67,6 +67,10 @@ msgstr "Dien" msgid "Unknown" msgstr "" +#: amt/site/templates/projects/index.html.j2:11 +msgid "Find project..." +msgstr "Fine projekt..." + #: amt/site/templates/projects/new.html.j2:4 msgid "New Project" msgstr "" diff --git a/amt/locale/nl_NL/LC_MESSAGES/messages.mo b/amt/locale/nl_NL/LC_MESSAGES/messages.mo index 5ffafc357..1d5e5d0b5 100644 Binary files a/amt/locale/nl_NL/LC_MESSAGES/messages.mo and b/amt/locale/nl_NL/LC_MESSAGES/messages.mo differ diff --git a/amt/locale/nl_NL/LC_MESSAGES/messages.po b/amt/locale/nl_NL/LC_MESSAGES/messages.po index 8f80d4595..8dcec56bc 100644 --- a/amt/locale/nl_NL/LC_MESSAGES/messages.po +++ b/amt/locale/nl_NL/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-07-26 13:53+0200\n" +"POT-Creation-Date: 2024-08-15 15:18+0200\n" "PO-Revision-Date: 2024-07-25 21:01+0200\n" "Last-Translator: FULL NAME \n" "Language: nl_NL\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.15.0\n" +"Generated-By: Babel 2.16.0\n" #: amt/site/templates/header.html.j2:4 msgid "Algorithm Management Toolkit" @@ -67,6 +67,10 @@ msgstr "Afgerond" msgid "Unknown" msgstr "Onbekend" +#: amt/site/templates/projects/index.html.j2:11 +msgid "Find project..." +msgstr "Zoek project..." + #: amt/site/templates/projects/new.html.j2:4 msgid "New Project" msgstr "Nieuw project" diff --git a/amt/migrations/versions/9804dd337d85_add_a_vector_fulltext_search_for_.py b/amt/migrations/versions/9804dd337d85_add_a_vector_fulltext_search_for_.py deleted file mode 100644 index 93147fc65..000000000 --- a/amt/migrations/versions/9804dd337d85_add_a_vector_fulltext_search_for_.py +++ /dev/null @@ -1,49 +0,0 @@ -"""add a vector fulltext search for project name - -Revision ID: 9804dd337d85 -Revises: 66cf279a7f62 -Create Date: 2024-08-14 11:36:29.020151 - -""" - -from collections.abc import Sequence -import logging -import sqlalchemy as sa -from alembic import op -from sqlalchemy_utils import TSVectorType - -# revision identifiers, used by Alembic. -revision: str = "9804dd337d85" -down_revision: str | None = "66cf279a7f62" -branch_labels: str | Sequence[str] | None = None -depends_on: str | Sequence[str] | None = None - -logger = logging.getLogger(__name__) - -def upgrade() -> None: - bind = op.get_bind() - if bind.engine.name == 'postgresql': - op.add_column("project", - sa.Column( - "__ts_vector__", - TSVectorType(), - sa.Computed("to_tsvector('english', name)", persisted=True), - nullable=True, - ) - ) - op.create_index("ix_project__ts_vector__", "project", ["__ts_vector__"], unique=False, postgresql_using="gin") - else: - with op.batch_alter_table("project", schema=None) as batch_op: - batch_op.add_column(sa.Column("__ts_vector__", sa.String(), nullable=True)) - logger.info("Creating dummy TSVector field for project title because database is not postgres") - - -def downgrade() -> None: - bind = op.get_bind() - if bind.engine.name == 'postgresql': - op.drop_index("ix_project__ts_vector__", "project", postgresql_using="gin") - op.drop_column("project", "__ts_vector__") - else: - with op.batch_alter_table("project", schema=None) as batch_op: - batch_op.drop_column("__ts_vector__") - logger.info("Creating dummy TSVector field for project title because database is not postgres") diff --git a/amt/models/project.py b/amt/models/project.py index 76b1526a2..8252abf81 100644 --- a/amt/models/project.py +++ b/amt/models/project.py @@ -1,10 +1,8 @@ from typing import TypeVar -from sqlalchemy import Computed, Index, String +from sqlalchemy import String from sqlalchemy.orm import Mapped, mapped_column -from sqlalchemy_utils import TSVectorType # pyright: ignore[reportMissingTypeStubs] -from amt.core.config import get_settings from amt.models.base import Base T = TypeVar("T", bound="Project") @@ -16,12 +14,3 @@ class Project(Base): id: Mapped[int] = mapped_column(primary_key=True) name: Mapped[str] = mapped_column(String(255)) # TODO: (Christopher) how to set min_length? model_card: Mapped[str | None] = mapped_column(default=None) - - if get_settings().APP_DATABASE_SCHEME == "postgresql": - ts_vector = mapped_column( - "__ts_vector__", TSVectorType(), Computed("to_tsvector('english', name)", persisted=True) - ) - else: - ts_vector = mapped_column("__ts_vector__", String()) - - __table_args__ = (Index("ix_project__ts_vector__", ts_vector, postgresql_using="gin"),) diff --git a/amt/repositories/projects.py b/amt/repositories/projects.py index 33cf3053d..efdf63b65 100644 --- a/amt/repositories/projects.py +++ b/amt/repositories/projects.py @@ -8,7 +8,6 @@ from sqlalchemy.orm import Session from sqlalchemy_utils import escape_like # pyright: ignore[reportMissingTypeStubs, reportUnknownVariableType] -from amt.core.config import get_settings from amt.core.exceptions import RepositoryError from amt.models import Project from amt.repositories.deps import get_session @@ -58,11 +57,7 @@ def paginate(self, skip: int, limit: int, search: str) -> list[Project]: try: statement = select(Project) if search != "": - search_wildcards = f"%{escape_like(search)}%" - if get_settings().APP_DATABASE_SCHEME == "postgresql": - statement = statement.filter(Project.name.ilike(search_wildcards) | Project.name.match(search)) - else: - statement = statement.filter(Project.name.ilike(search_wildcards)) + statement = statement.filter(Project.name.ilike(f"%{escape_like(search)}%")) statement = statement.order_by(func.lower(Project.name)).offset(skip).limit(limit) return list(self.session.execute(statement).scalars()) except Exception as e: diff --git a/amt/services/instruments.py b/amt/services/instruments.py index 391e2d3d3..443bf8cfc 100644 --- a/amt/services/instruments.py +++ b/amt/services/instruments.py @@ -32,7 +32,6 @@ def fetch_github_content(self, url: str) -> Instrument: return Instrument(**data) def fetch_instruments(self, urns: Sequence[str] | None = None) -> list[Instrument]: - # todo (Robbert): we 'type ignore' Task.sort_order because it works correctly, but pyright does not agree content_list = self.fetch_github_content_list() instruments: list[Instrument] = [] diff --git a/amt/site/templates/projects/index.html.j2 b/amt/site/templates/projects/index.html.j2 index 55de7e419..c5e9db20a 100644 --- a/amt/site/templates/projects/index.html.j2 +++ b/amt/site/templates/projects/index.html.j2 @@ -8,7 +8,7 @@