diff --git a/app/api.py b/app/api.py index df98b9d..3b451ac 100644 --- a/app/api.py +++ b/app/api.py @@ -163,5 +163,20 @@ async def index(request: Request, response: Response) -> Response: return JSONResponse(entries) + +@router.get('/removals') +async def removals(request: Request, response: Response) -> Response: + # get all packages in the pacman repo which are no in GIT + entries = [] + for s in state.sources.values(): + for k, p in s.packages.items(): + if p.name not in state.sourceinfos: + entries.append({ + "repo": p.repo, + "name": p.name, + }) + return JSONResponse(entries) + + api = FastAPI(title="MSYS2 Packages API", docs_url="/") api.include_router(router) diff --git a/app/templates/navbar.html b/app/templates/navbar.html index d354d46..3aaffa8 100644 --- a/app/templates/navbar.html +++ b/app/templates/navbar.html @@ -21,7 +21,4 @@ - + \ No newline at end of file diff --git a/app/templates/queue.html b/app/templates/queue.html index 8c94996..c6e6553 100644 --- a/app/templates/queue.html +++ b/app/templates/queue.html @@ -70,4 +70,36 @@ +
+
+

Pending Package Removals

+
+ {{ removals|length }} packages which are in the pacman repository, but no + longer in the Git repository and will be removed +
+
+
+ + + + + + + + + + + {% for s, p in removals %} + + + + + + + {% endfor %} + +
Change DateRepoPackageStatus
{{ p.builddate|timestamp }}{{ p.repo }}{{ p.name }}Ready for removal
+
+
+ {% endblock %} diff --git a/app/templates/removals.html b/app/templates/removals.html deleted file mode 100644 index 595f383..0000000 --- a/app/templates/removals.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "layout.html" %} -{% block title %}Pending Package Removals{% endblock %} -{% block inner_content %} - -
-
-

Pending Package Removals

-
- {{ missing|length }} packages which are in the pacman repository, but no - longer in the Git repository and will be removed -
-
-
- - - - - - - - - {% for s, p in missing %} - - - - - {% endfor %} - -
Change DatePackage
{{ p.builddate|timestamp }}{{ p.name }}
-
-
- -{% endblock %} diff --git a/app/web.py b/app/web.py index 3ce62da..5c12364 100644 --- a/app/web.py +++ b/app/web.py @@ -235,7 +235,7 @@ async def updates(request: Request, response: Response) -> Response: return templates.TemplateResponse("updates.html", { "request": request, - "packages": packages[:150], + "packages": packages[:250], }, headers=dict(response.headers)) @@ -374,33 +374,27 @@ async def queue(request: Request, response: Response) -> Response: key=lambda i: (i[0].date, i[0].pkgbase, i[0].pkgname), reverse=True) + # get all packages in the pacman repo which are no in GIT + removals = [] + for s in state.sources.values(): + for k, p in s.packages.items(): + if p.name not in state.sourceinfos: + removals.append((s, p)) + removals.sort(key=lambda i: (i[1].builddate, i[1].name), reverse=True) + return templates.TemplateResponse("queue.html", { "request": request, "updates": updates, + "removals": removals, }, headers=dict(response.headers)) @router.get('/new', dependencies=[Depends(Etag(get_etag))]) +@router.get('/removals', dependencies=[Depends(Etag(get_etag))]) async def new(request: Request, response: Response) -> Response: return RedirectResponse(request.url_for('queue'), headers=dict(response.headers)) -@router.get('/removals', dependencies=[Depends(Etag(get_etag))]) -async def removals(request: Request, response: Response) -> Response: - # get all packages in the pacman repo which are no in GIT - missing = [] - for s in state.sources.values(): - for k, p in s.packages.items(): - if p.name not in state.sourceinfos: - missing.append((s, p)) - missing.sort(key=lambda i: (i[1].builddate, i[1].name), reverse=True) - - return templates.TemplateResponse("removals.html", { - "request": request, - "missing": missing, - }, headers=dict(response.headers)) - - @router.get('/search', dependencies=[Depends(Etag(get_etag))]) async def search(request: Request, response: Response, q: str = "", t: str = "") -> Response: query = q diff --git a/tests/test_main.py b/tests/test_main.py index ded9a62..67c9c5e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -24,7 +24,7 @@ def client(): @pytest.mark.parametrize("endpoint", [ '', 'repos', 'base', 'group', 'updates', 'outofdate', 'queue', 'new', - 'removals', 'search', 'base/foo', 'group/foo', 'package/foo', + 'search', 'base/foo', 'group/foo', 'package/foo', 'package', ]) def test_main_endpoints(client, endpoint):