mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +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:
|
else:
|
||||||
flash("No downloads to create", "danger")
|
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:
|
else:
|
||||||
flash("Unknown action: " + action, "danger")
|
flash("Unknown action: " + action, "danger")
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@ from app.models import *
|
|||||||
|
|
||||||
@bp.route("/metapackages/")
|
@bp.route("/metapackages/")
|
||||||
def list_all():
|
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)
|
return render_template("meta/list.html", mpackages=mpackages)
|
||||||
|
|
||||||
@bp.route("/metapackages/<name>/")
|
@bp.route("/metapackages/<name>/")
|
||||||
|
@ -25,15 +25,17 @@
|
|||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<div class="row px-3">
|
<div class="row px-3">
|
||||||
<select name="action" class="custom-select col">
|
<select name="action" class="custom-select col">
|
||||||
<option value="delstuckreleases" selected>Delete stuck releases</option>
|
<option value="cleanuploads" selected>Delete unreachable uploads</option>
|
||||||
<option value="checkreleases">Validate all Zip releases</option>
|
<option value="delmetapackages">Delete unused meta packages</option>
|
||||||
|
<option value="delstuckreleases">Delete stuck releases</option>
|
||||||
<option value="reimportpackages">Reimport meta</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="importmodlist">Import forum topics</option>
|
||||||
<option value="importforeign">Import foreign release downloads</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="checkusers">Check forum users</option>
|
||||||
<option value="importscreenshots">Import screenshots from VCS</option>
|
<option value="importscreenshots">Import screenshots from VCS</option>
|
||||||
<option value="cleanuploads">Delete unreachable uploads</option>
|
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="Perform" class="col-sm-auto btn btn-primary ml-2" />
|
<input type="submit" value="Perform" class="col-sm-auto btn btn-primary ml-2" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,11 +5,36 @@ Meta Packages
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<ul>
|
<div class="list-group">
|
||||||
{% for meta in mpackages %}
|
<div class="list-group-item">
|
||||||
<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="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 %}
|
{% else %}
|
||||||
<li><i>No meta packages found.</i></li>
|
<li><i>No meta packages found.</i></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user