From 9f8e10330dd6ffe75785ea8fbd3beeaaa3ca16c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 12 Nov 2024 13:18:54 +0100 Subject: [PATCH] feat: allow user search to filter changes This allows to search from the info tab to match shown numbers. Fixes #12969 See also #11808 --- docs/changes.rst | 4 ++++ docs/user/search.rst | 7 +++++++ weblate/templates/snippets/info.html | 2 +- weblate/utils/search.py | 8 +++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 88ba862e2061..c41b62c0d2a1 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -3,6 +3,10 @@ Weblate 5.8.4 Not yet released. +**Improvements** + +* :ref:`search-users` can search based on user changes. + **Bug fixes** * Fixed occasional crash in :ref:`rss`. diff --git a/docs/user/search.rst b/docs/user/search.rst index 1794a4a3ab15..317ae7c6f517 100644 --- a/docs/user/search.rst +++ b/docs/user/search.rst @@ -3,6 +3,8 @@ Searching ========= +.. _search-strings: + Searching for strings +++++++++++++++++++++ @@ -178,6 +180,7 @@ There are many options to order the strings according to your needs: .. image:: /screenshots/query-sort.webp +.. _search-users: Searching for users +++++++++++++++++++ @@ -198,6 +201,10 @@ The user browsing has similar search abilities: User has contributed to a given language in the past 90 days. ``contributes:TEXT`` User has contributed to a given project or component in the past 90 days. +``change_time:DATETIME`` + Same as in :ref:`search-strings`. +``change_action:TEXT`` + Same as in :ref:`search-strings`. Additional lookups are available in the :ref:`management-interface`: diff --git a/weblate/templates/snippets/info.html b/weblate/templates/snippets/info.html index d35c03de12ad..b171801c7646 100644 --- a/weblate/templates/snippets/info.html +++ b/weblate/templates/snippets/info.html @@ -470,7 +470,7 @@

{% trans "Trends of last 30 days" %}

- +
{{ metrics.contributors|number_format }}
{% trans "Contributors" %}
diff --git a/weblate/utils/search.py b/weblate/utils/search.py index 6cf665a6d8d2..16d50b74d8f6 100644 --- a/weblate/utils/search.py +++ b/weblate/utils/search.py @@ -296,6 +296,9 @@ def convert_change_action(self, text: str) -> int: except KeyError: return Change.ACTION_STRINGS[text] + def convert_change_time(self, text: str) -> datetime | tuple[datetime, datetime]: + return self.convert_datetime(text) + def field_name(self, field: str, suffix: str | None = None) -> str: if suffix is None: suffix = OPERATOR_MAP[self.operator] @@ -536,9 +539,6 @@ def path_field(self, text: str, context: dict) -> Q: return Q(translation__language=obj) raise TypeError(f"Unsupported path lookup: {obj}") - def convert_change_time(self, text: str) -> datetime | tuple[datetime, datetime]: - return self.convert_datetime(text) - def convert_changed(self, text: str) -> datetime | tuple[datetime, datetime]: return self.convert_datetime(text) @@ -591,6 +591,8 @@ class UserTermExpr(BaseTermExpr): PLAIN_FIELDS: set[str] = {"username", "full_name"} NONTEXT_FIELDS: dict[str, str] = { "joined": "date_joined", + "change_time": "change__timestamp", + "change_action": "change__action", } EXACT_FIELD_MAP: dict[str, str] = { "language": "profile__languages__code",