[Collab-qa-commits] r1211 - in buildstat/trunk/buildstat-server: lib/SvnBuildStat/Controller root/src/packages script

goneri at alioth.debian.org goneri at alioth.debian.org
Sun Sep 7 01:27:59 UTC 2008


Author: goneri
Date: 2008-09-07 01:27:59 +0000 (Sun, 07 Sep 2008)
New Revision: 1211

Modified:
   buildstat/trunk/buildstat-server/lib/SvnBuildStat/Controller/Packages.pm
   buildstat/trunk/buildstat-server/root/src/packages/info.tt2
   buildstat/trunk/buildstat-server/root/src/packages/list.tt2
   buildstat/trunk/buildstat-server/script/svnbuildstat_import-new-report.pl
Log:
-info package has a view per repository
-improve the performance
-no more javascript style preload for the package lists


Modified: buildstat/trunk/buildstat-server/lib/SvnBuildStat/Controller/Packages.pm
===================================================================
--- buildstat/trunk/buildstat-server/lib/SvnBuildStat/Controller/Packages.pm	2008-09-07 01:25:47 UTC (rev 1210)
+++ buildstat/trunk/buildstat-server/lib/SvnBuildStat/Controller/Packages.pm	2008-09-07 01:27:59 UTC (rev 1211)
@@ -40,18 +40,55 @@
 }
 
 sub list : Local {
-    my ( $self, $c, $email ) = @_;
+    my ( $self, $c, $email, $repository_id ) = @_;
 
 # Do not remove
 # Avoid SQL injection ...
     die unless $email =~ /^[-\.\w\@]+$/;
+    die if $repository_id && $repository_id !~ /^\d+$/;
 
     my $dbh = $c->model('DB')->storage->dbh;
 
-    my $sth = $dbh->prepare("
+
+
+    my $req = "
+
+
+
 SELECT
-  vcs.name AS vcs_name, repository.name AS repository_name, sourcepackage.name AS sourcepackage_name, maintainer.email, maintainer.name, sourcepackage.id AS sourcepackage_id, changelogentry.id AS changelogentry_id, changelogentry.dscuri, changelogentry.isnative, changelogentry.isindebian, count(buildall.id) AS buildallcount, count(buildok.isbuildok) AS buildokcount, repositoryentry.issyncedwithupstream, repositoryentry.iswatchfilebroken
+  distinct(repository.id) AS repository_id,
+  repository.name AS repository_name,
+  vcs.name AS vcs_name
 FROM
+  repository,
+  repositoryentry,
+  repositoryentry_maintainer,
+  maintainer,
+  vcs
+WHERE
+  maintainer.email='$email'
+ AND
+  repositoryentry_maintainer.maintainer_id=maintainer.id
+ AND
+  repositoryentry_maintainer.repositoryentry_id=repositoryentry.id
+ AND
+  repositoryentry.repository_id=repository.id
+ AND
+  repository.vcs_id=vcs.id
+
+
+    ";
+    my $repositorys  = $dbh->selectall_arrayref($req, { Slice => {} });
+    $c->stash->{repositorys} = $repositorys;
+    $c->stash->{maintainer}->{email} = $email;
+
+    return unless $repository_id;
+    $c->stash->{repository_id} = $repository_id;
+
+    $req = "
+SELECT
+  repository.name AS repository_name, sourcepackage.name AS sourcepackage_name, maintainer.email, maintainer.name, sourcepackage.id AS sourcepackage_id, changelogentry.id AS changelogentry_id, changelogentry.dscuri, changelogentry.isnative, changelogentry.isindebian, count(buildall.id) AS buildallcount, count(buildok.isbuildok) AS buildokcount, repositoryentry.issyncedwithupstream, repositoryentry.iswatchfilebroken
+FROM
   sourcepackage, repositoryentry_maintainer, maintainer, changelogentry, repositoryentry
  LEFT OUTER JOIN build AS buildall
  ON
@@ -63,11 +100,12 @@
  LEFT OUTER JOIN repository
  ON
   repository.id=repositoryentry.repository_id
- LEFT OUTER JOIN vcs 
- ON
-  vcs.id=repository.vcs_id
 
 WHERE
+  repository.id=$repository_id
+ AND
+  maintainer.email='$email'
+ AND
   repositoryentry.id=repositoryentry_maintainer.repositoryentry_id
  AND
   repositoryentry.changelogentry_id=changelogentry.id
@@ -75,19 +113,18 @@
   maintainer.id=repositoryentry_maintainer.maintainer_id
  AND
   repositoryentry.sourcepackage_id=sourcepackage.id
- AND maintainer.email='$email'
- GROUP BY vcs.name, repository.name, sourcepackage.name, sourcepackage.id, changelogentry.id, changelogentry.dscuri, changelogentry.isnative, changelogentry.isindebian, repositoryentry.issyncedwithupstream, repositoryentry.iswatchfilebroken, maintainer.email, maintainer.name
- ORDER BY vcs.name, sourcepackage.name ");
+ GROUP BY repository.name, sourcepackage.name, sourcepackage.id, changelogentry.id, changelogentry.dscuri, changelogentry.isnative, changelogentry.isindebian, repositoryentry.issyncedwithupstream, repositoryentry.iswatchfilebroken, maintainer.email, maintainer.name
+ ORDER BY sourcepackage.name ";
 
-my $package_arrayref = $dbh->selectall_arrayref($sth, { Slice => {} });
+my $package_arrayref = $dbh->selectall_arrayref($req, { Slice => {} });
 
 
-
-    $c->stash->{maintainer}->{email} = $email;
     my $name_arrayref = $dbh->selectall_arrayref("SELECT name FROM maintainer WHERE email='$email'");
     $c->stash->{maintainer}->{name} = $name_arrayref->[0][0];
 
-    ($c->stash->{packages}, $c->stash->{vcses}) = preparePackages($dbh, $package_arrayref);
+print STDERR "before preparePackages ".time."\n";
+    $c->stash->{packages} = preparePackages($dbh, $package_arrayref);
+print STDERR "after preparePackages ".time."\n";
 
     $c->stash->{template} = 'packages/list.tt2';
 
@@ -97,29 +134,28 @@
 sub preparePackages : Private {
     my ($dbh, $package_arrayref) = @_;
 
+    my $sth_bug  = $dbh->prepare("select bug.id, bugstate.name AS state, bug.name AS desc, bugseverity.name AS severity from bug,bugstate, bugseverity where sourcepackage_id = ? and bug.bugstate_id=bugstate.id and bug.bugseverity_id=bugseverity.id and bugstate.name <> 'done'");
+    my $sth_lintian  = $dbh->prepare("select qaresultentry.id AS qaresultentry_id, qaseverity.letter, qatag.name AS tag, qaresultentry.text from qaseverity, qaresultentry, qatool, qajob, qatag where qajob.changelogentry_id=? and qaresultentry.qajob_id=qajob.id and qajob.qatool_id=qatool.id and qaresultentry.qatag_id=qatag.id and qatool.name='lintian' and qaresultentry.qaseverity_id=qaseverity.id");
 
-    my $vcses_cache = {};
     my $packages = [];
-    my $vcses = [];
     foreach (@$package_arrayref) {
 
-        # is used to create the repostiries menu
-        if (!$vcses_cache->{$_->{vcs_name}}) {
-            push @$vcses, { vcs_name => $_->{vcs_name}, repository_name => $_->{repository_name} };
-            $vcses_cache->{$_->{vcs_name}} = 1;
-        }
 
         # TODO prepare() the SQL request first to speed up the process
-        my $bug_hashref  = $dbh->selectall_hashref("select bug.id, bugstate.name AS state, bug.name AS desc, bugseverity.name AS severity from bug,bugstate, bugseverity where sourcepackage_id = ".$_->{sourcepackage_id}." and bug.bugstate_id=bugstate.id and bug.bugseverity_id=bugseverity.id and bugstate.name <> 'done'", 1);
+        $sth_bug->bind_param(1, $_->{sourcepackage_id});
+        my $bug_hashref  = $dbh->selectall_hashref($sth_bug, 1);
        
+        # TODO use selectall_arraref with Slice=>{} here
         $_->{bugs} = [];
         foreach my $bug_id (keys %$bug_hashref) {
             push @{$_->{bugs}}, $bug_hashref->{$bug_id};
         }
 
 
-        my $lintian_hashref  = $dbh->selectall_hashref("select qaresultentry.id AS qaresultentry_id, qaseverity.letter, qatag.name AS tag, qaresultentry.text from qaseverity, qaresultentry, qatool, qajob, qatag where qajob.changelogentry_id=".$_->{changelogentry_id}." and qaresultentry.qajob_id=qajob.id and qajob.qatool_id=qatool.id and qaresultentry.qatag_id=qatag.id and qatool.name='lintian' and qaresultentry.qaseverity_id=qaseverity.id", 1);
+        $sth_lintian->bind_param(1, $_->{changelogentry_id});
+        my $lintian_hashref  = $dbh->selectall_hashref($sth_lintian, 1);
        
+        # TODO use selectall_arraref with Slice=>{} here
         $_->{lintians} = [];
         foreach my $qaresultentry_id (keys %$lintian_hashref) {
             push @{$_->{lintians}}, $lintian_hashref->{$qaresultentry_id};
@@ -130,22 +166,51 @@
 
     }
 
-    return ($packages, $vcses);
+    return $packages;
 
 
 
 } 
 
 sub info : Local {
-    my ($self, $c, $packagename) = @_;
-
+    my ($self, $c, $packagename, $repository_id) = @_;
+    # TODO replace repository_id by repositoryentry_id
     die unless $packagename =~ /^\S+$/;
+    die if $repository_id && $repository_id !~ /^\d+$/;
 
     my $dbh = $c->model('DB')->storage->dbh;
-    
-    my $req = "SELECT
+  
+
+    my $req = "
+SELECT
+  repository.id AS repository_id,
+  repository.name AS repository_name,
+  vcs.name AS vcs_name
+FROM
+  repository,
+  repositoryentry,
+  sourcepackage,
+  vcs
+WHERE
+  repositoryentry.repository_id=repository.id
+ AND
+  repositoryentry.sourcepackage_id=sourcepackage.id
+ AND
+  sourcepackage.name='$packagename'
+ AND
+  repository.vcs_id=vcs.id
+    ";
+    my $repositorys  = $dbh->selectall_arrayref($req, { Slice => {} });
+    $c->stash->{sourcepackage_name} = $packagename;
+    $c->stash->{repositorys} = $repositorys;
+
+    return unless $repository_id;
+
+    $c->stash->{repository_id} = $repository_id;
+
+
+    $req = "SELECT
           sourcepackage.name as sourcepackage_name,
-          vcs.name as vcs_name,
           versioninsid,
           istarballpresent,
           upstreamversion,
@@ -172,47 +237,31 @@
           sourcepackage,
           repositoryentry,
           repository,
-          vcs,
           changelogentry
         WHERE
           sourcepackage.name = '".$packagename."'
          AND
+          repository.id=$repository_id
+         AND
           repositoryentry.sourcepackage_id=sourcepackage.id
          AND
           repositoryentry.repository_id=repository.id
          AND
-          repository.vcs_id=vcs.id
-         AND
           repositoryentry.changelogentry_id=changelogentry.id
-        ORDER BY
-          vcs_name";
-#          print $req;
-    my $packageinfo  = $dbh->selectall_hashref($req, 1);
+        ";
+    my $packageinfo  = $dbh->selectrow_hashref($req);
 
-    if (!$packageinfo || !%$packageinfo) {
-        $c->response->redirect($c->uri_for('/'));
-        return;
-    }
 
-    # The idea behind that is to have be able to provide the information if the package is on different vcs
-    my @vcses = keys %$packageinfo;
-    my $vcs = $vcses[0];
-#    my @currentchangelogentry = split $/, $package->currentchangelogentry;
-#    my @todo = split $/, $package->todo;
-    $c->stash->{package} = $packagename;
+
     $c->stash->{bugpic} = $packagename;
     $c->stash->{bugpic} =~ s!^(.)(.+)$!http://people.debian.org/~glandium/bts/$1/$1$2.png! ;
-#    $c->stash->{istarballpresent} = $packageinfo->{$vcs}->{istarballpresent};
-#    print Dumper($packageinfo->{$vcs});
-    foreach (keys %{$packageinfo->{$vcs}}) {
-        $c->stash->{$_} = $packageinfo->{$vcs}->{$_};
-    }
+    $c->stash->{packageinfo} = $packageinfo;
 
     ############ Maintainers list
-    my $maintainer_rs = $c->model('SvnBuildStat::Model::DB::RepositoryentryMaintainer')->search({repositoryentry_id => $packageinfo->{$vcs}->{'repositoryentry_id'}});
+    my $maintainer_rs = $c->model('SvnBuildStat::Model::DB::RepositoryentryMaintainer')->search({repositoryentry_id => $packageinfo->{'repositoryentry_id'}});
     $c->stash->{maintainers} = [ $maintainer_rs->search_related("maintainer_id")->all ];
 
-    my $bugsinfo  = $dbh->selectall_hashref("select bug.id as bug_id, bug.name as bug_name, bugseverity.name AS bugseverity_name, isreleasecritic  from bug, bugseverity where bug.bugseverity_id=bugseverity.id and sourcepackage_id = ".$packageinfo->{$vcs}->{'sourcepackage_id'}, 1);
+    my $bugsinfo  = $dbh->selectall_hashref("select bug.id as bug_id, bug.name as bug_name, bugseverity.name AS bugseverity_name, isreleasecritic  from bug, bugseverity where bug.bugseverity_id=bugseverity.id and sourcepackage_id = ".$packageinfo->{'sourcepackage_id'}, 1);
 
     foreach (keys %$bugsinfo) {
         my $bug_name = $bugsinfo->{$_}->{bug_name};
@@ -250,15 +299,11 @@
 WHERE
   changelogentry.userlogin_id=userlogin.id
  AND
-  repositoryentry_id=".$packageinfo->{$vcs}->{'repositoryentry_id'}."
+  repositoryentry_id=".$packageinfo->{'repositoryentry_id'}."
 ORDER BY
   date DESC", { Slice => {} });
 
     foreach my $changelogentry (@$changelogs) {
-#        my %h;
-#        foreach (keys %{$changelogsinfo->{$changelogentry->{changelogentry_id}}) {
-#            $h{$_} = $changelogsinfo->{$changelogentry>{changelogentry_id}->{$_};
-#        }
 
         # Fetch the builds 
         my %t;
@@ -291,8 +336,6 @@
             foreach my $qaresultentry_id (keys %{$qaresultentrysinfo}) {
                 push @{$buildsinfo->{$build_id}->{qaresultentrys}}, $qaresultentrysinfo->{$qaresultentry_id};
             }
-#            if ($buildsinfo->{$build_id} and !exists($buildsinfo->{$build_id})) {
-#            $changelogentry->{builds} = [];
 
             #           }
             push @{$changelogentry->{builds}}, $buildsinfo->{$build_id};

Modified: buildstat/trunk/buildstat-server/root/src/packages/info.tt2
===================================================================
--- buildstat/trunk/buildstat-server/root/src/packages/info.tt2	2008-09-07 01:25:47 UTC (rev 1210)
+++ buildstat/trunk/buildstat-server/root/src/packages/info.tt2	2008-09-07 01:27:59 UTC (rev 1211)
@@ -14,6 +14,21 @@
   [% END -%]
 </table>
 
+
+
+<div id="repositoriesmenu">
+Package avalaible in:
+<ul>
+  [% FOREACH repository IN repositorys %]
+  <li>[% IF repository_id == repository.repository_id %]<strong>[% END %]
+   <a href="/packages/info/[% sourcepackage_name %]/[% repository.repository_id %]">[% repository.repository_name %]( [% repository.vcs_name %] )</a> 
+  [% IF repository_id == repository.repository_id %]</strong>[% END %]
+  [% END %]
+  </li>
+  </ul>
+</div>
+
+
 [% IF ! isindebian %]
   <h2><a href="#" onclick="showhide('currentchangelogentry'); return(false);">This release is not yet in Debian</a></h2>
   <div id="currentchangelogentry">

Modified: buildstat/trunk/buildstat-server/root/src/packages/list.tt2
===================================================================
--- buildstat/trunk/buildstat-server/root/src/packages/list.tt2	2008-09-07 01:25:47 UTC (rev 1210)
+++ buildstat/trunk/buildstat-server/root/src/packages/list.tt2	2008-09-07 01:27:59 UTC (rev 1211)
@@ -25,39 +25,25 @@
 [% END %]
 </h1>
 
-
 <div id="repositoriesmenu">
-
-
-[% FOREACH vcs IN vcses -%]
-  <a href="#" onclick="[% FOREACH vcs2 IN vcses -%]showhide('list[% vcs2.vcs_name %]');[% END %]return(false);">
-  [ [% vcs.repository_name _ ' ( ' _ vcs.vcs_name _ ' )' %] ] </a>
-
-[% END %]
+Package avalaible in:
+<ul>
+  [% FOREACH repository IN repositorys %]
+  <li>[% IF repository_id == repository.repository_id %]<strong>[% END %]
+   <a href="/packages/list/[% maintainer.email %]/[% repository.repository_id %]">[% repository.repository_name %]( [% repository.vcs_name %] )</a> 
+  [% IF repository_id == repository.repository_id %]</strong>[% END %]
+  [% END %]
+  </li>
+  </ul>
 </div>
 
 
-[% # Display each book in a table row %]
-[% FOREACH package IN packages -%]
 
-
-[% IF current_vcs_name != package.vcs_name %]
-</table>
-</div>
-[% END %]
-
-[% IF current_vcs_name != package.vcs_name %]
-<div class="lists" id="list[% package.vcs_name %]" [% IF current_vcs_name != 'apt' %]style="display: none"[% END %] >
-<h1>[% package.repository_name _ ' ( ' _ package.vcs_name _ ' )' %]</h1>
-[% current_vcs_name = package.vcs_name %]
 <table>
 <tr><th>Packages</th><th>Status</th><th>Lintian</th><th>Bugs</th><!--<th>Piuparts--></th>[% IF current_vcs_name != 'apt' %]<th>Synced<br />with<br />Debian</th>[% END %]<th>Synced<br />with<br />Upstream</th></tr>
-[% END %]
 
+[% FOREACH package IN packages -%]
 
-
-
-
       [% IF ! package.dscuri %]
         [% buildstatus = 'no-src-pkg' %] 
       [% ELSE %]
@@ -95,7 +81,7 @@
 
   <tr>
     <td>
-    <a href="[% Catalyst.uri_for('info/') _ package.sourcepackage_name %]"><strong>[% package.sourcepackage_name %]</strong></a>
+    <a href="[% Catalyst.uri_for('info/') _ package.sourcepackage_name %]/[% repository_id %]"><strong>[% package.sourcepackage_name %]</strong></a>
     </td>
     <td 
     [% IF buildstatus == 'no-src-pkg' %]class="error"[% END %]
@@ -104,12 +90,12 @@
     [% IF buildstatus == 'ok' %]class="ok"[% END %]
     >
      
-    <a href="[% Catalyst.uri_for('info/') _ package.sourcepackage_name %]">
+    <a href="[% Catalyst.uri_for('info/') _ package.sourcepackage_name %]/[% repository_id %]">
       [% buildstatus %]
       </a>
     </td>
     <td [% IF lintianerrcount > 0 %]class="error"[% ELSE %][% IF lintiancount > 0 %]class="warning"[% ELSE %][% IF package.isbuildok %]class="ok"[% END %][% END %][% END %]>
-    <a href="[% Catalyst.uri_for('info/') _ package.sourcepackage_name %]"  onMouseOver="ShowHelpbox('[% lintianstring | html | replace ("'", '&#96') %]')" onMouseOut="HideHelpBox()">
+    <a href="[% Catalyst.uri_for('info/') _ package.sourcepackage_name %]/[% repository_id %]"  onMouseOver="ShowHelpbox('[% lintianstring | html | replace ("'", '&#96') %]')" onMouseOut="HideHelpBox()">
         [% IF lintiancount > 0 %][% lintiancount %][% END %]
       </a>
     </td>
@@ -148,7 +134,7 @@
     </td>
     [% END %]
     <td [% IF package.iswatchfilebroken || package.issyncedwithupstream == 0 %]class="error"[% ELSE %][% IF package.issyncedwithupstream == 1 || package.isnative == 1 %]class="ok"[% ELSE %]class="warning"[% END %][% END %]>
-    <a href="[% Catalyst.uri_for('info/') _ package.name %]">
+    <a href="[% Catalyst.uri_for('info/') _ package.name %]/[% repository_id %]">
         [% IF package.isnative == 1 %]
 	  Native
         [% ELSE %]

Modified: buildstat/trunk/buildstat-server/script/svnbuildstat_import-new-report.pl
===================================================================
--- buildstat/trunk/buildstat-server/script/svnbuildstat_import-new-report.pl	2008-09-07 01:25:47 UTC (rev 1210)
+++ buildstat/trunk/buildstat-server/script/svnbuildstat_import-new-report.pl	2008-09-07 01:27:59 UTC (rev 1211)
@@ -183,8 +183,8 @@
   }
   copy ($dir.'/'.$infofile->{logfile}, $fullBuildResultDirectory."/build.log") or warn;
   copy ($File::Find::name, $fullBuildResultDirectory."/build.info") or warn;
+  print "LOG ARE IN->".$fullBuildResultDirectory."\n";
 
-
   my @localfile;
   foreach (split(' ', $infofile->{files})) {
     next unless /(deb|diff\.gz|dsc|changes)$/;
@@ -220,6 +220,19 @@
     print $tarball."\n";
     system("ln $tarball $debTargetDirectory/");
   }
+
+
+  # Avoid the bsd_glob here for better performance
+  # should use getFullBuildResultDirectory()
+  print '/var/lib/buildstat-server/repository/'.$changelogentry->repositoryentry_id->repository_id->id.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build->id."/deb/*.changes\n";
+
+   my $changesfile = bsd_glob('/var/lib/buildstat-server/repository/'.$changelogentry->repositoryentry_id->repository_id->id.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build->id."/deb/*.changes");
+   if ($changesfile) {
+       print STDERR "changesuri can be set: ".$changesfile."\n";
+       $changelogentry->changesuri("http://buildstat.debian.net/repository/".$changelogentry->repositoryentry_id->repository_id->id.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build->id."/deb/".basename($changesfile));
+   }
+
+
   updateLastBuildSymlink(\$build);
 
 }




More information about the Collab-qa-commits mailing list