Merge the package removals in the update queue
And add an API for it as well
This commit is contained in:
15
app/api.py
15
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)
|
||||
|
||||
@@ -21,7 +21,4 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if is_endpoint('queue') else '' }}" href="{{ url_for('queue') }}">Update Queue</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if is_endpoint('removals') else '' }}" href="{{ url_for('removals') }}">Removal Queue</a>
|
||||
</li>
|
||||
</li>
|
||||
@@ -70,4 +70,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title">Pending Package Removals</h4>
|
||||
<h6 class="card-subtitle mb-2 text-muted">
|
||||
{{ removals|length }} packages which are in the pacman repository, but no
|
||||
longer in the Git repository and will be removed
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body overflow-auto">
|
||||
<table class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Change Date</th>
|
||||
<th>Repo</th>
|
||||
<th>Package</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for s, p in removals %}
|
||||
<tr>
|
||||
<td><a href="{{ s.history_url }}">{{ p.builddate|timestamp }}</a></td>
|
||||
<td>{{ p.repo }}</td>
|
||||
<td><a href="{{ package_url(p) }}">{{ p.name }}</a></td>
|
||||
<td>Ready for removal</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block title %}Pending Package Removals{% endblock %}
|
||||
{% block inner_content %}
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title">Pending Package Removals</h4>
|
||||
<h6 class="card-subtitle mb-2 text-muted">
|
||||
{{ missing|length }} packages which are in the pacman repository, but no
|
||||
longer in the Git repository and will be removed
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body overflow-auto">
|
||||
<table class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Change Date</th>
|
||||
<th>Package</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for s, p in missing %}
|
||||
<tr>
|
||||
<td><a href="{{ s.history_url }}">{{ p.builddate|timestamp }}</a></td>
|
||||
<td><a href="{{ package_url(p) }}">{{ p.name }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
28
app/web.py
28
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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user