mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add ability to delete unused metapackages
This commit is contained in:
parent
2f208d9239
commit
5db633d911
@ -150,6 +150,16 @@ def admin_page():
|
||||
else:
|
||||
flash("No downloads to create", "danger")
|
||||
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
|
||||
elif action == "delmetapackages":
|
||||
query = MetaPackage.query.filter(~MetaPackage.dependencies.any(), ~MetaPackage.packages.any())
|
||||
count = query.count()
|
||||
query.delete(synchronize_session=False)
|
||||
db.session.commit()
|
||||
|
||||
flash("Deleted " + str(count) + " unused meta packages", "success")
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
else:
|
||||
flash("Unknown action: " + action, "danger")
|
||||
|
||||
|
@ -24,7 +24,10 @@ from app.models import *
|
||||
|
||||
@bp.route("/metapackages/")
|
||||
def list_all():
|
||||
mpackages = MetaPackage.query.order_by(db.asc(MetaPackage.name)).all()
|
||||
mpackages = db.session.query(MetaPackage, func.count(MetaPackage.id)) \
|
||||
.select_from(MetaPackage).outerjoin(MetaPackage.packages) \
|
||||
.order_by(db.asc(MetaPackage.name)) \
|
||||
.group_by(MetaPackage.id).all()
|
||||
return render_template("meta/list.html", mpackages=mpackages)
|
||||
|
||||
@bp.route("/metapackages/<name>/")
|
||||
|
@ -25,15 +25,17 @@
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<div class="row px-3">
|
||||
<select name="action" class="custom-select col">
|
||||
<option value="delstuckreleases" selected>Delete stuck releases</option>
|
||||
<option value="checkreleases">Validate all Zip releases</option>
|
||||
<option value="cleanuploads" selected>Delete unreachable uploads</option>
|
||||
<option value="delmetapackages">Delete unused meta packages</option>
|
||||
<option value="delstuckreleases">Delete stuck releases</option>
|
||||
<option value="reimportpackages">Reimport meta</option>
|
||||
<option value="recalcscores">Recalculate package scores</option>
|
||||
<option value="div">------</option>
|
||||
<option value="checkreleases">Validate all Zip releases</option>
|
||||
<option value="importmodlist">Import forum topics</option>
|
||||
<option value="importforeign">Import foreign release downloads</option>
|
||||
<option value="recalcscores">Recalculate package scores</option>
|
||||
<option value="checkusers">Check forum users</option>
|
||||
<option value="importscreenshots">Import screenshots from VCS</option>
|
||||
<option value="cleanuploads">Delete unreachable uploads</option>
|
||||
</select>
|
||||
<input type="submit" value="Perform" class="col-sm-auto btn btn-primary ml-2" />
|
||||
</div>
|
||||
|
@ -5,11 +5,36 @@ Meta Packages
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<ul>
|
||||
{% for meta in mpackages %}
|
||||
<li><a href="{{ url_for('metapackages.view', name=meta.name) }}">{{ meta.name }}</a> ({{ meta.packages.filter_by(soft_deleted=False, approved=True).all() | count }} packages)</li>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item">
|
||||
<div class="row text-muted">
|
||||
<div class="col-sm">
|
||||
{{ _("Name") }}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1 text-center">
|
||||
{{ _("Packages") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% for pair in mpackages %}
|
||||
{% set meta = pair[0] %}
|
||||
{% set count = pair[1] %}
|
||||
<a class="list-group-item list-group-item-action"
|
||||
href="{{ url_for('metapackages.view', name=meta.name) }}">
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
{{ meta.name }}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1 text-center">
|
||||
{{ count }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
<li><i>No meta packages found.</i></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user