Fix queue sorting for real

It was passing the display text to the sort function, not the
enum value, so only worked by accident. Refactor/rename things a
bit to make this more clear.

Also give the unknown/unprocessed state a higher priority, so it
shows up before the finished builds. Same for manual builds, since
they require user action.
This commit is contained in:
Christoph Reiter 2025-01-17 18:39:21 +01:00
parent 2adcca84ae
commit 04fbe06c18
2 changed files with 23 additions and 14 deletions

View File

@ -79,12 +79,12 @@
<td></td>
<td class="text-version">{{ srcinfo.build_version }}</td>
<td class="mytooltip text-{{ status[0].category or 'muted' }}">
{{ status[0].status }}
{{ status[0].status_text }}
{% for s in status %}
<small class="text-muted">
{% if s.urls %}
<br>
{{ s.type }}:
{{ s.build_type }}:
{% for key, value in s.urls.items() -%}
{% if not loop.first %} / {% endif %}<a href="{{ s.urls[key] }}">{{ key }}</a>
{%- endfor -%}
@ -95,7 +95,7 @@
<template class="mytooltip-content">
<dl>
{% for s in status %}
<dt>{{ s.type }}: <span class="text-{{ s.category or 'muted' }}">{{ s.status }}</span></dt>
<dt>{{ s.build_type }}: <span class="text-{{ s.category or 'muted' }}">{{ s.status_text }}</span></dt>
<dd><small class="text-muted">
{% if s.details %}
{{ s.details }}

View File

@ -42,11 +42,22 @@ class PackageStatus(Enum):
class PackageBuildStatus(NamedTuple):
type: str
status: str
build_type: str
status_key: str
details: str
urls: dict[str, str]
category: str
@property
def status_text(self) -> str:
return get_status_text(self.status_key)
@property
def category(self) -> str:
return get_status_category(self.status_key)
@property
def priority(self) -> tuple[int, str]:
return get_status_priority(self.status_key)
async def get_etag(request: Request) -> str:
@ -582,13 +593,13 @@ def get_status_priority(key: str) -> tuple[int, str]:
return (-1, key)
order = [
PackageStatus.UNKNOWN,
PackageStatus.FINISHED,
PackageStatus.MANUAL_BUILD_REQUIRED,
PackageStatus.FINISHED_BUT_INCOMPLETE,
PackageStatus.FINISHED_BUT_BLOCKED,
PackageStatus.WAITING_FOR_BUILD,
PackageStatus.WAITING_FOR_DEPENDENCIES,
PackageStatus.UNKNOWN,
PackageStatus.MANUAL_BUILD_REQUIRED,
PackageStatus.FAILED_TO_BUILD,
]
@ -632,16 +643,14 @@ def get_build_status(srcinfo: SrcInfoPackage, build_types: set[str] = set()) ->
continue
results.append(
PackageBuildStatus(
build_type, get_status_text(status_key),
status.desc or "", status.urls,
get_status_category(status_key))
build_type, status_key,
status.desc or "", status.urls)
)
if not results:
for build in build_types:
key = "unknown"
results.append(
PackageBuildStatus(build, get_status_text(key), "", {}, get_status_category(key)))
PackageBuildStatus(build, PackageStatus.UNKNOWN.value, "", {}))
return results
@ -693,7 +702,7 @@ async def queue(request: Request, response: Response, build_type: str = "") -> R
updates: list[UpdateEntry] = []
updates = list(grouped.values())
updates.sort(
key=lambda i: (get_status_priority(i[3][0].status), i[0].date, i[0].pkgbase, i[0].pkgname),
key=lambda i: (i[3][0].priority, i[0].date, i[0].pkgbase, i[0].pkgname),
reverse=True)
# get all packages in the pacman repo which are no in GIT