Skip to content

Commit

Permalink
Use https when applicable on mirrors report
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-suse committed Sep 28, 2023
1 parent 3185fa4 commit e5837a4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/MirrorCache/Schema/ResultSet/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ select s.id, s.region, s.country,
s.sponsor, s.sponsor_url,
s.hostname as hostname,
concat(s.hostname, s.urldir) as url,
case when (select rating from server_stability where capability = 'http' and server_id = s.id) > 0 then concat('http://', s.hostname, '/', s.urldir, '/') else '' end as http_url,
case when (select rating from server_stability where capability = 'https' and server_id = s.id) > 0 then concat('https://', s.hostname, '/', s.urldir, '/') else '' end as https_url,
case when (select rating from server_stability where capability = 'http' and server_id = s.id and server_stability.dt > now() - interval '1 day') > 0 then concat('http://', s.hostname, '/', s.urldir, '/') else '' end as http_url,
case when (select rating from server_stability where capability = 'https' and server_id = s.id and server_stability.dt > now() - interval '1 day') > 0 then concat('https://', s.hostname, '/', s.urldir, '/') else '' end as https_url,
( select msg from server_note where kind = 'Ftp' and server_note.hostname = s.hostname order by server_note.dt desc limit 1) as ftp_url,
( select msg from server_note where kind = 'Rsync' and server_note.hostname = s.hostname order by server_note.dt desc limit 1) as rsync_url,
project,
Expand Down Expand Up @@ -347,6 +347,9 @@ join project_folder_count on project_folder_count.project_id = smry.project_id
join server s on smry.server_id = s.id and s.enabled
order by region, country, score, hostname, project;
END_SQL

$sql =~ s/interval '1 day'/interval 1 day/g unless ($dbh->{Driver}->{Name} eq 'Pg');

my $prep = $dbh->prepare($sql);
if ($project && $region) {
$prep->execute($project, $project, $region);
Expand Down
6 changes: 6 additions & 0 deletions t/environ/14-project-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ sleep 1
$mc/sql "insert into server_note(dt,hostname,kind,msg) select now(), '$($ap7/print_address)','Rsync', 'rsync://rsync.ap7.com/opensuse'"
$mc/sql "insert into server_note(dt,hostname,kind,msg) select now(), '$($ap6/print_address)','Rsync', 'rsync://rsync.ap6.com/opensuse'"

$mc/sql "insert into server_stability(dt,server_id,rating,capability) select now(), 1, 1000, 'https'"
$mc/sql "insert into server_stability(dt,server_id,rating,capability) select now(), 1, 1000, 'http'"
$mc/sql "insert into server_stability(dt,server_id,rating,capability) select now(), 1, 1000, 'ipv6'"
$mc/sql "insert into server_stability(dt,server_id,rating,capability) select now(), 2, 0, 'https'"
$mc/sql "insert into server_stability(dt,server_id,rating,capability) select now(), 2, 100, 'http'"


$mc/backstage/job -e folder_sync -a '["/project1/folder1"]'
$mc/backstage/job -e mirror_scan -a '["/project1/folder1"]'
Expand Down
16 changes: 13 additions & 3 deletions templates/report/mirrors/index.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ div.sponsor {
max-width: 10pct;
}

a.sponsor {
font-size: smaller;
}

tr:nth-child(even) {
background-color: #88888822;
}
Expand Down Expand Up @@ -181,8 +185,14 @@ td.newregion, tr:hover td.newregion {
% }
% $prev_region = $region;
<tr>
% my $hostname = $m->{hostname};
% my $url = $m->{url};
% my $hostname = $m->{hostname};
% my $url = 'http://' . $m->{url};
% my $url_https = $m->{https_url};
% my $url_http = $m->{http_url};
% $url_http =~ s/(\/)+$//g; # truncate trailing slashes
% $url_https =~ s/(\/)+$//g; # truncate trailing slashes
% $url = $url_http if $url_http;
% $url = $url_https if $url_https;
<td><div class="country"><%= $m->{country} %></div>
% if ($country_image_dir) {
<div class="flag"><img src="/<%= $m->{country} %>.png" width="20" class="img-fluid" alt="country flag"></div>
Expand Down Expand Up @@ -232,7 +242,7 @@ td.newregion, tr:hover td.newregion {
title="diff in: <%=$victim%>"
% }
% $second = 'iso' if $second eq 'ISO' || $second eq 'ISOs';
href="http://<%=$url . $path%>">
href="<%=$url . $path%>">
<%= $second %>
</a>
</div>
Expand Down

0 comments on commit e5837a4

Please sign in to comment.