feat: add "Last Updated" column to search results

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2023-01-18 21:55:01 +01:00
parent becce1aac4
commit ec239ceeb3
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
3 changed files with 23 additions and 1 deletions

View file

@ -102,6 +102,7 @@ async def packages_get(
models.PackageBase.Popularity,
models.PackageBase.NumVotes,
models.PackageBase.OutOfDateTS,
models.PackageBase.ModifiedTS,
models.User.Username.label("Maintainer"),
models.PackageVote.PackageBaseID.label("Voted"),
models.PackageNotification.PackageBaseID.label("Notify"),

View file

@ -68,6 +68,16 @@
{{ "Maintainer" | tr }}
</a>
</th>
<th>
{% if SB == "l" %}
{% set order = reverse_order %}
{% else %}
{% set order = SO %}
{% endif %}
<a href="/packages?{{ q | extend_query(('O', 0), ('SB', 'l'), ('SO', order)) | urlencode }}">
{{ "Last Updated" | tr }}
</a>
</th>
</tr>
</thead>
<tbody>
@ -115,6 +125,11 @@
<span class="error">{{ "orphan" | tr }}</span>
{% endif %}
</td>
{% if flagged %}
<td class="flagged">{{ datetime_display(pkg.ModifiedTS) }}</td>
{% else %}
<td>{{ datetime_display(pkg.ModifiedTS) }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>

View file

@ -5,7 +5,8 @@ from unittest import mock
import pytest
from fastapi.testclient import TestClient
from aurweb import asgi, db, time
from aurweb import asgi, config, db, time
from aurweb.filters import datetime_display
from aurweb.models import License, PackageLicense
from aurweb.models.account_type import USER_ID, AccountType
from aurweb.models.dependency_type import DependencyType
@ -1085,6 +1086,11 @@ def test_packages_sort_by_last_modified(client: TestClient, packages: list[Packa
col = row.xpath("./td")[0].xpath("./a")[0]
assert col.text.strip() == package.Name
# Make sure our row contains the modified date we've set
tz = config.get("options", "default_timezone")
dt = datetime_display({"timezone": tz}, package.PackageBase.ModifiedTS)
assert dt in "".join(row.itertext())
def test_packages_flagged(
client: TestClient, maintainer: User, packages: list[Package]