Skip to content

Commit

Permalink
Remove progres specific token search
Browse files Browse the repository at this point in the history
  • Loading branch information
uittenbroekrobbert committed Aug 15, 2024
1 parent 7e8c9d3 commit bd4866e
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 79 deletions.
2 changes: 0 additions & 2 deletions amt/clients/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
8 changes: 6 additions & 2 deletions amt/locale/base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
Expand Down Expand Up @@ -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 ""
Expand Down
Binary file modified amt/locale/en_US/LC_MESSAGES/messages.mo
Binary file not shown.
8 changes: 6 additions & 2 deletions amt/locale/en_US/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language: en_US\n"
Expand All @@ -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"
Expand Down Expand Up @@ -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 ""
Expand Down
Binary file modified amt/locale/nl_FY/LC_MESSAGES/messages.mo
Binary file not shown.
8 changes: 6 additions & 2 deletions amt/locale/nl_FY/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language: nl_FY\n"
Expand All @@ -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"
Expand Down Expand Up @@ -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 ""
Expand Down
Binary file modified amt/locale/nl_NL/LC_MESSAGES/messages.mo
Binary file not shown.
8 changes: 6 additions & 2 deletions amt/locale/nl_NL/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language: nl_NL\n"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

This file was deleted.

13 changes: 1 addition & 12 deletions amt/models/project.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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"),)
7 changes: 1 addition & 6 deletions amt/repositories/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion amt/services/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down
2 changes: 1 addition & 1 deletion amt/site/templates/projects/index.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<input
size="100"
type="search"
placeholder="{% trans %}Find projects...{% endtrans %}"
placeholder="{% trans %}Find project...{% endtrans %}"
name="search"
hx-get="/projects/?skip=0"
hx-trigger="input changed delay:500ms, search"
Expand Down
2 changes: 2 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ services:
- PGDATA=/var/lib/postgresql/data/pgdata
healthcheck:
test: ["CMD", "pg_isready", "-q", "-d", "amt", "-U", "amt"]
ports:
- 5432:5432

db-admin:
image: dpage/pgadmin4:8.6
Expand Down

0 comments on commit bd4866e

Please # to comment.