Skip to content

Commit

Permalink
Propagation page: sort by number of mirrors
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Jun 5, 2024
1 parent c5e0374 commit 1d48c0c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
20 changes: 18 additions & 2 deletions mirrormanager2/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import datetime
import random
import string
from collections import defaultdict
from contextlib import contextmanager

import sqlalchemy as sa
Expand Down Expand Up @@ -988,9 +989,24 @@ def get_propagation_repos(session):
"""
query = (
sa.select(model.Repository).join(model.PropagationStat).order_by(model.Repository.prefix)
sa.select(
model.Repository,
sa.func.avg(
model.PropagationStat.same_day
+ model.PropagationStat.one_day
+ model.PropagationStat.two_day
+ model.PropagationStat.older
+ model.PropagationStat.no_info
).label("host_count"),
)
.join(model.PropagationStat)
.order_by(model.Repository.prefix, sa.desc("host_count"))
.group_by(model.Repository)
)
return session.scalars(query).unique()
repo_by_version = defaultdict(list)
for repo in session.scalars(query):
repo_by_version[repo.version].append(repo)
return repo_by_version


def get_propagation(session, repo_id):
Expand Down
18 changes: 12 additions & 6 deletions mirrormanager2/templates/fedora/propagation.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ <h1>Propagation{% if repo %} for {{ repo.version.product.name }} {{ repo.version
<p>The same diagram is also available for the following versions:</p>

<ul>
{%- for repo_with_stats in repos -%}
{%- for version in repos|sort(attribute="product.name,name") -%}
<li>
<a
class="{% if repo and repo_with_stats.id == repo.id %}font-weight-bold{% endif %}"
href="{{url_for('base.propagation', repo_id=repo_with_stats.id)}}"
{{ version.product.name }} {{ version.name }}:
{% for repo_with_stats in repos[version] -%}
<a
class="{% if repo and repo_with_stats.id == repo.id %}font-weight-bold{% endif %}"
href="{{url_for('base.propagation', repo_id=repo_with_stats.id)}}"
{% if not loop.first %}title="Mirrors which don't contain the main arch"{% endif %}
>
{{ repo_with_stats.version.product.name }} {{ repo_with_stats.version.name }} ({{ repo_with_stats.arch.name }})
</a>
{{ repo_with_stats.arch.name }}
</a>
{% if loop.first and loop.length > 1 %} (main) {% endif %}
{%- if not loop.last %},{% endif %}
{% endfor -%}
</li>
{%- endfor -%}
</ul>
Expand Down

0 comments on commit 1d48c0c

Please sign in to comment.