Commit f2a67b661942e9d84501a3ce4fd76ce7a3677638
1 parent
adf63596
Exists in
master
add tooltip with submitters to copr versions
Showing
2 changed files
with
24 additions
and
35 deletions
Show diff stats
lib/Copr/Api.pm
| ... | ... | @@ -19,10 +19,18 @@ sub get_project_id { |
| 19 | 19 | sub get_project_builds { |
| 20 | 20 | my ( $user, $repo ) = @_; |
| 21 | 21 | my $project_id = get_project_id($user, $repo); |
| 22 | - my $builds_json = get("$copr_base_url/api_2/builds?limit=0&project_id=$project_id"); | |
| 23 | - my $json = JSON->new->allow_nonref; | |
| 24 | - my $builds_data = $json->decode($builds_json); | |
| 25 | - return @{$builds_data->{builds}}; | |
| 22 | + my @builds; | |
| 23 | + my $limit = 100; | |
| 24 | + my $offset = 0; | |
| 25 | + while($limit == 100) { | |
| 26 | + my $builds_json = get("$copr_base_url/api_2/builds?project_id=$project_id&limit=100&offset=$offset"); | |
| 27 | + my $json = JSON->new->allow_nonref; | |
| 28 | + my $builds_data = $json->decode($builds_json); | |
| 29 | + push(@builds, @{$builds_data->{builds}}); | |
| 30 | + $offset += (scalar @builds); | |
| 31 | + $limit = (scalar @builds); | |
| 32 | + } | |
| 33 | + return @builds; | |
| 26 | 34 | } |
| 27 | 35 | |
| 28 | 36 | # gets all latest builds of each package | ... | ... |
lib/CoprStatus.pm
| ... | ... | @@ -6,6 +6,7 @@ use YAML::XS 'LoadFile'; |
| 6 | 6 | use Text::Template; |
| 7 | 7 | use LWP::UserAgent; |
| 8 | 8 | use LWP::Simple; |
| 9 | +use Copr::Api; | |
| 9 | 10 | |
| 10 | 11 | $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; |
| 11 | 12 | |
| ... | ... | @@ -13,11 +14,6 @@ $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; |
| 13 | 14 | our $info = {}; |
| 14 | 15 | my $config = LoadFile('config.yaml'); |
| 15 | 16 | |
| 16 | -sub copr_monitor_url { | |
| 17 | - my ( $user, $repo ) = @_; | |
| 18 | - return "http://copr.fedoraproject.org/api/coprs/$user/$repo/monitor/"; | |
| 19 | -} | |
| 20 | - | |
| 21 | 17 | sub git_url { |
| 22 | 18 | my ( $domain, $spec_path, $branch, $package ) = @_; |
| 23 | 19 | |
| ... | ... | @@ -50,12 +46,6 @@ sub download_specs { |
| 50 | 46 | } |
| 51 | 47 | } |
| 52 | 48 | |
| 53 | -sub download_copr_versions { | |
| 54 | - my ( $user, $repo ) = @_; | |
| 55 | - `mkdir -p data/copr/$user/$repo`; | |
| 56 | - my $result = mirror(copr_monitor_url($user, $repo), "data/copr/$user/$repo/monitor.json"); | |
| 57 | -} | |
| 58 | - | |
| 59 | 49 | sub get_specs { |
| 60 | 50 | my ( $branch ) = @_; |
| 61 | 51 | foreach my $package (keys %{$info}) { |
| ... | ... | @@ -77,17 +67,12 @@ sub get_specs { |
| 77 | 67 | |
| 78 | 68 | sub get_copr_versions { |
| 79 | 69 | my ( $user, $repo ) = @_; |
| 80 | - return unless -e "data/copr/$user/$repo/monitor.json"; | |
| 81 | - open(my $fh, "<", "data/copr/$user/$repo/monitor.json") or die; | |
| 82 | - my $result = do { local $/; <$fh> }; | |
| 83 | - close($fh); | |
| 84 | - my $json = JSON->new->allow_nonref; | |
| 85 | - my $dec_result = $json->decode($result); | |
| 86 | - foreach(@{$dec_result->{'packages'}}) { | |
| 87 | - my $package = $_->{'pkg_name'}; | |
| 88 | - my $status = $_->{'results'}{'epel-7-x86_64'}{'status'}; | |
| 89 | - my $version = $_->{'results'}{'epel-7-x86_64'}{'pkg_version'}; | |
| 90 | - $info->{$package}->{'copr'}->{$repo} = $version if $status eq "succeeded"; | |
| 70 | + my %latest_packages = Copr::Api::get_latest_packages($user, $repo); | |
| 71 | + foreach my $package (keys %latest_packages) { | |
| 72 | + my $version = $latest_packages{$package}{version}; | |
| 73 | + my $submitter = $latest_packages{$package}{submitter}; | |
| 74 | + $info->{$package}->{'copr'}->{$repo}->{version} = $version; | |
| 75 | + $info->{$package}->{'copr'}->{$repo}->{submitter} = $submitter; | |
| 91 | 76 | } |
| 92 | 77 | } |
| 93 | 78 | |
| ... | ... | @@ -105,10 +90,6 @@ sub update_info { |
| 105 | 90 | sub update_files { |
| 106 | 91 | while(1) { |
| 107 | 92 | my $user = $config->{User}; |
| 108 | - foreach my $repo (@{$config->{Repositories}}) { | |
| 109 | - download_copr_versions($user, $repo); | |
| 110 | - } | |
| 111 | - | |
| 112 | 93 | my $repo_index = 0; |
| 113 | 94 | foreach my $branch (@{$config->{Branches}}) { |
| 114 | 95 | download_specs($branch, $user, ${$config->{Repositories}}[$repo_index]); |
| ... | ... | @@ -123,7 +104,7 @@ sub compare_versions { |
| 123 | 104 | update_info(); |
| 124 | 105 | my $match = {}; |
| 125 | 106 | foreach my $package (keys %{$info}) { |
| 126 | - if($info->{$package}->{'copr'}->{${$config->{Repositories}}[1]} eq $info->{$package}->{'git'}->{${$config->{Branches}}[1]}) { | |
| 107 | + if($info->{$package}->{'copr'}->{${$config->{Repositories}}[1]}->{version} eq $info->{$package}->{'git'}->{${$config->{Branches}}[1]}) { | |
| 127 | 108 | $match->{$package} = 1; |
| 128 | 109 | } |
| 129 | 110 | else { |
| ... | ... | @@ -140,14 +121,14 @@ sub info2html { |
| 140 | 121 | foreach my $package (keys %{$info}) { |
| 141 | 122 | my $fill_stable_row; |
| 142 | 123 | my $fill_dev_row; |
| 143 | - if($info->{$package}->{'copr'}->{${$config->{Repositories}}[0]} eq $info->{$package}->{'git'}->{${$config->{Branches}}[0]}) { | |
| 124 | + if($info->{$package}->{'copr'}->{${$config->{Repositories}}[0]}->{version} eq $info->{$package}->{'git'}->{${$config->{Branches}}[0]}) { | |
| 144 | 125 | $fill_stable_row = "success"; |
| 145 | 126 | } |
| 146 | 127 | else { |
| 147 | 128 | $fill_stable_row = "danger"; |
| 148 | 129 | } |
| 149 | 130 | |
| 150 | - if($info->{$package}->{'copr'}->{${$config->{Repositories}}[1]} eq $info->{$package}->{'git'}->{${$config->{Branches}}[1]}) { | |
| 131 | + if($info->{$package}->{'copr'}->{${$config->{Repositories}}[1]}->{version} eq $info->{$package}->{'git'}->{${$config->{Branches}}[1]}) { | |
| 151 | 132 | $fill_dev_row = "success"; |
| 152 | 133 | } |
| 153 | 134 | else { |
| ... | ... | @@ -157,9 +138,9 @@ sub info2html { |
| 157 | 138 | $table_entries .= "<tr> |
| 158 | 139 | <td><b>$package</b></td> |
| 159 | 140 | <td>$info->{$package}->{'git'}->{${$config->{Branches}}[0]}</td> |
| 160 | - <td class=\"$fill_stable_row\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Submitter:\">$info->{$package}->{'copr'}->{${$config->{Repositories}}[0]}</td> | |
| 141 | + <td class=\"$fill_stable_row\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Submitter: $info->{$package}->{'copr'}->{${$config->{Repositories}}[0]}->{submitter}\">$info->{$package}->{'copr'}->{${$config->{Repositories}}[0]}->{version}</td> | |
| 161 | 142 | <td>$info->{$package}->{'git'}->{${$config->{Branches}}[1]}</td> |
| 162 | - <td class=\"$fill_dev_row\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Submitter:\">$info->{$package}->{'copr'}->{${$config->{Repositories}}[1]}</td> | |
| 143 | + <td class=\"$fill_dev_row\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Submitter: $info->{$package}->{'copr'}->{${$config->{Repositories}}[1]}->{submitter}\">$info->{$package}->{'copr'}->{${$config->{Repositories}}[1]}->{version}</td> | |
| 163 | 144 | </tr>"; |
| 164 | 145 | } |
| 165 | 146 | ... | ... |