Skip to content

Commit

Permalink
Add /rest/project_last_modified route (#506)
Browse files Browse the repository at this point in the history
The idea is to help to confirm whether a rsync is needed for mirrors
  • Loading branch information
andrii-suse authored Aug 1, 2024
1 parent 77768b7 commit 584c140
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/MirrorCache/WebAPI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ sub _setup_webui {
# $rest_r->get('/project/:name')->to('project#show');
$rest_r->get('/project/:id')->to('table#list', table => 'Project');
$rest_r->get('/project/propagation/:project_id')->to('project_propagation#list');
$rest_r->get('/project_last_modified')->to('project#last_modified');
$rest_r->get('/rollout_server/:version')->to('rollout_server#list');

my $rest_operator_auth;
Expand Down
9 changes: 9 additions & 0 deletions lib/MirrorCache/WebAPI/Controller/Rest/Project.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ sub list {
$self->render(json => $list);
}

sub last_modified {
my ($self) = @_;

my $name = $self->param("project");
my $prj = $self->schema->resultset('Project')->find({ name => $name });

$self->render(text => $prj->lm, status => 200);
}

1;
4 changes: 4 additions & 0 deletions t/environ/14-project-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ $mc/sql_test 4 == "select file_cnt from project where path = '/project1'"
$mc/sql_test 2 == "select file_cnt from project where path = '/project2/folder1'"
$mc/sql_test 13 == "select size from project where path = '/project2/folder2'"

lm=$($mc/curl /rest/project_last_modified?project=proj1)

test "$lm" == "$(date +%s -r $mc/dt/project1/folder2/file1.1.dat)"

$mc/curl /report/mirrors | tidy --drop-empty-elements no | \
grep -A4 -F '<div class="repo">' | \
grep -A2 -F '"http://127.0.0.1:1304/project2/folder2">' | \
Expand Down

0 comments on commit 584c140

Please sign in to comment.