Skip to content

Commit

Permalink
Hide disabled mirrors in report
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-suse committed Aug 15, 2022
1 parent 39b6c47 commit 89866ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/MirrorCache/Schema/ResultSet/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ from (
group by server_id, project_id, name
) smry
join project_folder_count on project_folder_count.project_id = smry.project_id
join server s on smry.server_id = s.id
join server s on smry.server_id = s.id and s.enabled
order by region, country, score, url, project;
END_SQL
my $prep = $dbh->prepare($sql);
Expand Down
12 changes: 11 additions & 1 deletion t/environ/14-project-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ ap7=$(environ ap7)
ap6=$(environ ap6)
ap5=$(environ ap5)
ap4=$(environ ap4)
ap3=$(environ ap3)

for x in $mc $ap7 $ap8 $ap6 $ap5 $ap4; do
for x in $mc $ap7 $ap8 $ap6 $ap5 $ap4 $ap3; do
mkdir -p $x/dt/{folder1,folder2,folder3}
mkdir -p $x/dt/project1/{folder1,folder2,folder3}
mkdir -p $x/dt/project2/{folder1,folder2,folder3}
Expand All @@ -20,6 +21,7 @@ for x in $mc $ap7 $ap8 $ap6 $ap5 $ap4; do
echo $x/dt/project2/{folder1,folder2,folder3}/{file1.1,file2.1}.dat | xargs -n 1 touch
done

$ap3/start
$ap4/start
$ap5/start
$ap6/start
Expand All @@ -38,6 +40,7 @@ $mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($a
$mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap8/print_address)','','t','de','eu'"
$mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap5/print_address)','','t','cn','as'"
$mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap4/print_address)','','t','jp','as'"
$mc/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap3/print_address)','','f','jp','as'"

$mc/sql "insert into project(name,path,etalon) select '2.0 1','/project2/folder1', 3"
$mc/sql "insert into project(name,path,etalon) select 'proj1','/project1', 3"
Expand All @@ -64,3 +67,10 @@ $mc/curl /report/mirrors | tidy --drop-empty-elements no | \
grep -C3 '\b2\b' | \
grep -C3 -F '</a>'


rc=0
# no disabled mirror in the report
$mc/curl /report/mirrors | grep $($ap3/print_address) || rc=$?
test $rc -gt 0

echo success
1 change: 1 addition & 0 deletions t/lib/environ/mc/source/sql.sh.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
test "$MIRRORCACHE_DB_PROVIDER" != mariadb || {

sql=${1/"'t'"/"1"}
sql=${1/"'f'"/"0"}
sql=${sql/"extract(epoch from now())"/"unix_timestamp()"}

re="(update|insert|select)(.*)\s([a-z_A-Z]*)((\([a-z_0-9]*\))?) - interval '([0-9]+) (month|day|hour|minute|second)'(.*)$"
Expand Down

0 comments on commit 89866ec

Please sign in to comment.