[Dehs-devel] r122 - in trunk: . www

atomo64-guest at alioth.debian.org atomo64-guest at alioth.debian.org
Mon Mar 24 17:45:38 UTC 2008


Author: atomo64-guest
Date: 2008-03-24 17:45:37 +0000 (Mon, 24 Mar 2008)
New Revision: 122

Added:
   trunk/events.class.php
Modified:
   trunk/dehs.sh
   trunk/dehs_pg.php
   trunk/www/maintainer.php
   trunk/www/no_updated.php
   trunk/www/no_upstream.php
   trunk/www/no_watch.php
Log:
Drop built-in popcon parser in favor of qa.d.o's BDB to reduce work load:
 now storing the pop_* values in the pkg table instead of binpkgs
Separate the events class to an other file
Add other kind of runs to dehs.sh so e.g. the popcon info is updated by a cronjob and not on every run

Modified: trunk/dehs.sh
===================================================================
--- trunk/dehs.sh	2008-03-20 05:02:15 UTC (rev 121)
+++ trunk/dehs.sh	2008-03-24 17:45:37 UTC (rev 122)
@@ -35,6 +35,7 @@
 echo $$ > $LOCK
 
 run_type="-update_all"
+update_www=1
 
 if [ ! -z "$1" ]; then
     case $1 in
@@ -50,6 +51,17 @@
         wwiz)
                 run_type="-wwiz"
         ;;
+        popcon)
+                run_type="-dl_popcon -db_popcon"
+        ;;
+        bugs)
+                run_type="-db_up_error"
+                update_www=0
+        ;;
+        db)
+                run_type="-dehsqa_db"
+                update_www=0
+        ;;
         *)
                 echo "Unknown run-type: $1" >&2
                 exit 1
@@ -57,7 +69,6 @@
     esac
 fi
 
-#(cd /tmp/; svn export svn://svn/devscripts/trunk/scripts/uscan.pl && mv uscan.pl $WORKDIR/) || true
 cd /tmp/
 if svn export svn://svn/devscripts/trunk/scripts/uscan.pl 1>/dev/null; then
 	sed -i "s/###VERSION###/DEHS-SVN/g" uscan.pl
@@ -67,7 +78,12 @@
 	rm -f uscan.pl
 fi
 
-$WORKDIR/dehs_pg.php $run_type >$WORKDIR/logs/stdout.log
-$WORKDIR/update_wwwal.sh >/dev/null || $WORKDIR/update_wwwal.sh >/dev/null
+for rt in $run_type; do
+	$WORKDIR/dehs_pg.php $rt >$WORKDIR/logs/stdout.log
+done
 
+if [ $update_www -gt 0 ]; then
+	$WORKDIR/update_wwwal.sh >/dev/null || $WORKDIR/update_wwwal.sh >/dev/null
+fi
+
 rm $LOCK

Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php	2008-03-20 05:02:15 UTC (rev 121)
+++ trunk/dehs_pg.php	2008-03-24 17:45:37 UTC (rev 122)
@@ -28,6 +28,7 @@
 ini_set ( "memory_limit", "40M");
 #print_R($_SERVER);
 require "dehs.config.inc";
+require "events.class.php";
 dir_ctrl($dirs);
 if (!function_exists('file_get_contents')) {
     function file_get_contents($filename) {
@@ -63,7 +64,7 @@
     elseif (in_array("-dl_diffs",$argv) || in_array("-keep_diff",$argv))  dl_diffs($argv[2]);
     elseif (in_array("-keep_sources",$argv) || in_array("-download_sources",$argv))  download_sources();
     elseif (in_array("-db_popcon",$argv))  db_popcon($argv[2]);
-    elseif (in_array("-dl_popcon",$argv) || in_array("-keep_popcon",$argv))  dl_popcon($argv[2]);
+    elseif (in_array("-dl_popcon",$argv) || in_array("-keep_popcon",$argv))  dl_popcon();
     elseif (in_array("-db_upstream",$argv))  db_upstream((!empty($argv[2])?$argv[2]:'%'));
     elseif (in_array("-update_all",$argv))  update_all();
     elseif (in_array("-update_new",$argv))  update_new();
@@ -248,9 +249,8 @@
 function db_query($pkg,$dist='%') {
     global $dirs,$dbconn;
     $db = pg_pconnect($dbconn )  or  die_status(pg_last_error($db));
-    $rsql=pg_exec($db, "SELECT pkgs.* ,mpop_inst FROM (SELECT name,MAX(binpkgs.pop_inst) AS mpop_inst FROM binpkgs GROUP BY name)
-									AS binpkgs INNER JOIN pkgs ON pkgs.name=binpkgs.name
-		              WHERE pkgs.name='$pkg' AND dist='$dist';");
+    $rsql=pg_exec($db, "SELECT * FROM  pkgs
+		              WHERE name='$pkg' AND dist LIKE '$dist';");
     while ($res_array=pg_fetch_array($rsql)) {
         print "Package=> " . $res_array['name'] . "\n";
         print "Version => " . $res_array['version'] . "\n";
@@ -260,7 +260,7 @@
         print "Distribution => " . $res_array['dist'] . "\n";
         print "Section => " . $res_array['section'] . "\n";
         print "KBytes => " . number_format ( $res_array['bytes']/1024, 2, ",",".") . "\n";
-        print "Pop Inst=>" . $res_array['mpop_inst'] . "\n";
+        print "Pop Inst=>" . $res_array['pop_inst'] . "\n";
         if ($res_array['watch']) {
             $uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$res_array['watch']);
             print "Version Upstream => " . $uscan_res['uversion'] . "\n";
@@ -345,9 +345,10 @@
     global $dirs,$dbconn;
     $db = pg_pconnect($dbconn) or die_status(1/*pg_last_notice($db)*/);
     if (!pg_table_exists($db, "pkgs")) {
-        pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text, dversionmangled text,maint text, uploaders text, dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,up_changes text, up_url text,watch_warn text,updated bool, keep_changes bool, wwiz text,wwiz_version text, wwiz_type text, lastcheck timestamp, homepage text, vcs_browser text, lastupvsdebsync timestamp)") or die_status('Error creating table pkgs\n');
+        pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text, dversionmangled text,maint text, uploaders text, dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,up_changes text, up_url text,watch_warn text,updated bool, keep_changes bool, wwiz text,wwiz_version text, wwiz_type text, lastcheck timestamp, homepage text, vcs text,  vcs_type text, vcs_browser text, lastupvsdebsync timestamp, pop_inst numeric,pop_vote numeric)") or die_status('Error creating table pkgs\n');
         pg_exec($db, "CREATE UNIQUE INDEX idxname on pkgs (name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
         pg_exec($db, "CREATE INDEX checkx on pkgs (lastcheck)") or die_status('Errore creating index - ' . pg_last_error($db));
+        pg_exec($db, "CREATE INDEX maintx on pkgs (maint)") or die_status('Errore creating index - ' . pg_last_error($db));
         $sw=true;
     }
     if (!pg_table_exists($db, "binpkgs")) {
@@ -356,11 +357,15 @@
         $sw=true;
     }
     if (!pg_table_exists($db, "events")) {
-        pg_exec($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text, stamp timestamp, content text)") or die_status('Error creating table binpkgs\n');
-        pg_exec($db, "CREATE UNIQUE INDEX idxevents on events (name,dist,content)") or die_status('Errore creating index - ' . pg_last_error($db));
-        pg_exec($db, "CREATE INDEX pkgxeventtype on events (name,type,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
+        pg_exec($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text, stamp timestamp, content text)") or die_status('Error creating table events\n');
+        pg_exec($db, "CREATE UNIQUE INDEX idxevents on events (name,dist,content)") or die_status('Error creating index - ' . pg_last_error($db));
+        pg_exec($db, "CREATE INDEX pkgxeventtype on events (name,type,dist)") or die_status('Error creating index - ' . pg_last_error($db));
         $sw=true;
     }
+    if (!pg_table_exists($db, "stamps")) {
+        pg_exec($db, "CREATE TABLE stamps (type text PRIMARY KEY, stamp timestamp, pid text)") or die_status('Error creating table stamps\n');
+        $sw=true;
+    }
     #if (!pg_table_exists($db,"upstream")){
     #  pg_exec($db, "CREATE TABLE upstream (name text,dist text,up_version text,watch_warn text,updated bool)") or die_status('Errore nel creare la tabella');
     #  pg_exec($db, "CREATE UNIQUE INDEX idxupstrm on upstream (name,dist)") or die_status('Errore nel creare gli indici ' . pg_last_error($db));
@@ -414,42 +419,43 @@
 function db_popcon($initial='') {
     global $dirs,$dbconn;
     $db = pg_pconnect($dbconn)  or  die_status(pg_last_error($db));
-    $filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";
-    /*                   package name   vote     old    recent  nofiles*/
-    $regexp="/Package:\s($initial\S*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/iS";
-    $zp = gzopen($filename, "r") or die_status("Could not open $filename");
-    $tin=time();
-    if(filesize($filename)>20) {
-        #pg_exec($db, "BEGIN TRANSACTION") OR die_status("Impossibile iniziare la transazione");
-        while (!gzeof($zp)) {
-            $line = gzgets ($zp,4096) ;
-            if (preg_match($regexp,$line,$matches)) {
-                $pop_inst = $matches[2] + $matches[3] + $matches[4] + $matches[5];
-                #print "\rName => $matches[1] Install => $matches[2] Vote => $matches[3]";
-                @pg_exec($db, "UPDATE binpkgs SET pop_inst='$pop_inst',pop_vote='$matches[2]' WHERE bin_name='$matches[1]'");
-                /*$processed++;
-                $elapsed_time=time()-$tin;
-                if (($elapsed_time % 20)==0 AND $updtime!=$elapsed_time) {
-                    $updtime=$elapsed_time;
-                    $wprocessed=$processed-$wprocessed;
-                    $avg_time=$wprocessed/20;
-                    $wprocessed=$processed;
-                    $countdown=(34701- $processed)/$avg_time;
-                    $last_time=time();
-                }
-                print "\rProcessing Popcon: " .  date("i:s",$countdown=$countdown-(time()-$last_time))   . " =>" . (34701-$processed) . " Media $avg_time";
-                $last_time=time();*/
-            }
+    $filename=$dirs[popcon_dir] . "/popcon.db";
+    $popcon_db = dba_open("$filename", 'r-', 'db4');
+
+    $rsql = pg_exec($dbconn, "SELECT name FROM pkgs");
+
+    while ($res_array=pg_fetch_array($rsql)) {
+        $package = $res_array['name'];
+
+        if (!dba_exists('p:' .  $package)) {
+            continue;
         }
-        #pg_exec($db, "COMMIT") OR die_status("Impossibile commsionare la transazione");
+
+        $inst = dba_fetch("pi:$package", $popcon_db);
+        $vote = dba_fetch("pv:$package", $popcon_db);
+
+        @pg_exec($db, "UPDATE pkgs SET pop_inst='$inst',pop_vote='$vote' WHERE name='$package'");
     }
+
+    dba_close($popcon_db);
     @pg_close($db);
 }
 function dl_popcon() {
     global $dirs,$dbconn;
-    $localfile=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";
-    $remotefile="http://popcon.debian.org/all-popcon-results.txt.gz";
-    @file_put_contents($localfile,file_get_contents($remotefile),'w') or die_status("Errore nello scaricare il file popcon\n");
+
+    $localtempfile=$dirs[popcon_dir] . "/popcon.db.new";
+    $localfile=$dirs[popcon_dir] . "/popcon.db";
+    $remotefile='http://qa.debian.org/data/popcon/popcon.db';
+
+    $return = 0;
+    exec('/usr/bin/wget -qNc -O'.escapeshellarg($localtempfile).' ' . escapeshellarg($remotefile), $return);
+
+    if ($return != 0) {
+        echo __FUNCTION__ . "wget exited with status $return!\n";
+        return false;
+    }
+
+    return copy($localtempfile, $localfile);
 }
 function is_updated ($up_vers,$debian_vers, $dversionAsIs = false) {
     if ($up_vers=='') return 1;
@@ -754,7 +760,7 @@
     $postWHERE = '';
     if ($checkStamps) {
         $postWHERE = "AND (lastcheck<='".sqldate(time() - ($minimumAge*24*3600))."' OR lastcheck IS NULL)"
-                   . "AND wwiz_type!='no_cright' AND wwiz_type!='notmatch'";
+                   . " AND wwiz_type!='no_cright' AND wwiz_type!='notmatch'";
     }
 
     $postORDER = '';
@@ -762,8 +768,7 @@
     	$postORDER = 'LIMIT ' . $limit;
     }
 
-    $sqlstring="SELECT mpop_inst,name,pkgs.version,pkgs.dversionmangled,pkgs.section,pkgs.dist,tot_up_error, tot_avg_error_date, wwiz_version FROM pkgs INNER JOIN
-	(Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist HAVING max(pop_inst) IS NOT NULL) as binpkgs using(name,dist)
+    $sqlstring="SELECT name,version,dversionmangled,section,dist, wwiz_version FROM pkgs
 	WHERE (watch IS NULL OR watch='') AND name LIKE '$src_name' $postWHERE ORDER BY lastcheck DESC $postORDER";
     $rsql=pg_exec($db, $sqlstring);
 
@@ -962,8 +967,6 @@
     $intime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
     echo __FUNCTION__ . ' started the ' . $intime . "\n";
     db_add();
-    dl_popcon();
-    db_popcon();
     dl_diffs();
     db_up_error();
     db_upstream('%', in_array('all', $timeStamp_basedCheck));
@@ -982,8 +985,6 @@
     $intime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
     echo __FUNCTION__ . ' started the ' . $intime . "\n";
     db_add();
-    dl_popcon();
-    db_popcon();
 
     global $dbconn;
     check_db();
@@ -1052,121 +1053,6 @@
     }
 }
 
-class events
-{
-
-    function DB($db = null)
-    {
-        static $_db;
-
-        if ($db === null) {
-            return $_db;
-        }
-        $_db = $db;
-    }
-
-    function newVersion($sourcePackage, $currentVersion, $newVersion, $distribution, $downloadLink = '')
-    {
-        global $base, $sendNotifications;
-
-        if (!$sendNotifications) {
-            return null;
-        }
-
-        $eventsId = events::_searchEvent(__FUNCTION__, $sourcePackage, $newVersion);
-
-        if (!empty($eventsId)) {
-            echo "\nSkipping ".__FUNCTION__." event for v$newVersion of $sourcePackage; already sent";
-            return null;
-        }
-
-        $tpl = file_get_contents($base . '/tpls/new_version.mail.tpl');
-
-        $search  = array();
-        $replace = array();
-
-        $search [] = '#PACKAGE#';
-        $replace[] = $sourcePackage;
-        $search [] = '#DVERSION#';
-        $replace[] = $currentVersion;
-        $search [] = '#UVERSION#';
-        $replace[] = $newVersion;
-        $search [] = '#DISTRO#';
-        $replace[] = $distribution;
-        $search [] = '#LINK#';
-        $replace[] = $downloadLink;
-
-        $message = str_replace($search, $replace, $tpl);
-        $subject = events::_extractHeader('subject', $message);
-        $to      = events::_extractHeader('to', $message);
-        $bcc     = events::_extractHeader('bcc', $message);
-
-        $extraHeaders = events::_getDefaultExtraHeaders();
-        $extraHeaders[] = 'X-DEHS-UVERSION: ' . $newVersion;
-        $extraHeaders[] = 'BCC: ' . $bcc;
-
-        if (!mail($to, $subject, $message, implode("\r\n", $extraHeaders), escapeshellarg($to)))
-        return false;
-
-        events::_recordEvent(__FUNCTION__, $sourcePackage, $distribution, $newVersion);
-    }
-
-    function _extractHeader($header, &$message)
-    {
-        $regex  = '/' . preg_quote($header, '/') . ':([ \t]*)(.*)/i';
-
-        $matches = array();
-
-        if (preg_match($regex, $message, $matches)) {
-
-            $spacer = $matches[1];
-            $value  = $matches[2];
-
-            $message = trim(preg_replace($regex, '', $message));
-
-            return $value;
-
-        }
-        return false;
-    }
-
-    function _getDefaultExtraHeaders()
-    {
-        global $notificationsMailFrom;
-        $headers = array();
-
-        $headers[] = 'From: ' . $notificationsMailFrom;
-//        $headers[] = 'X-PTS-Approved: sure';
-        $headers[] = 'X-BY-DEHS: sure';
-
-        return $headers;
-    }
-
-    function _recordEvent($eventType, $packageName, $distribution, $content)
-    {
-        $db = events::DB();
-
-        $eventType    = pg_escape_string($eventType);
-        $packageName  = pg_escape_string($packageName);
-        $distribution = pg_escape_string($distribution);
-        $content      = pg_escape_string($content);
-
-        pg_exec($db, "INSERT INTO events (name,type,dist,content,stamp) VALUES ('$packageName','$eventType','$distribution','$content',now())") OR die_status("Failed to record event: $packageName|$eventType|$distribution|$content");
-    }
-
-    function _searchEvent($eventType, $packageName, $contentSearch, $distribution = '')
-    {
-        $db = events::DB();
-
-        $eventType    = pg_escape_string($eventType);
-        $packageName  = pg_escape_string($packageName);
-
-        $result = pg_exec($db, "SELECT id FROM events WHERE name='$packageName' and type='$eventType' ".($distribution? "and dist='$distribution'":'')." and content LIKE '$contentSearch'");
-        return pg_fetch_all($result);
-    }
-
-}
-
 function sqldate($timestamp=null) {
         if ($timestamp===null) $timestamp=time();
         return gmdate("Y-m-d H:i:s", $timestamp);

Added: trunk/events.class.php
===================================================================
--- trunk/events.class.php	                        (rev 0)
+++ trunk/events.class.php	2008-03-24 17:45:37 UTC (rev 122)
@@ -0,0 +1,136 @@
+<?php
+
+/***
+Copyright 2008 by Raphael Geissert <atomo64 at gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+class events
+{
+
+    function DB($db = null)
+    {
+        static $_db;
+
+        if ($db === null) {
+            return $_db;
+        }
+        $_db = $db;
+    }
+
+    function newVersion($sourcePackage, $currentVersion, $newVersion, $distribution, $downloadLink = '')
+    {
+        global $base, $sendNotifications;
+
+        if (!$sendNotifications) {
+            return null;
+        }
+
+        $eventsId = events::_searchEvent(__FUNCTION__, $sourcePackage, $newVersion);
+
+        if (!empty($eventsId)) {
+            echo "\nSkipping ".__FUNCTION__." event for v$newVersion of $sourcePackage; already sent";
+            return null;
+        }
+
+        $tpl = file_get_contents($base . '/tpls/new_version.mail.tpl');
+
+        $search  = array();
+        $replace = array();
+
+        $search [] = '#PACKAGE#';
+        $replace[] = $sourcePackage;
+        $search [] = '#DVERSION#';
+        $replace[] = $currentVersion;
+        $search [] = '#UVERSION#';
+        $replace[] = $newVersion;
+        $search [] = '#DISTRO#';
+        $replace[] = $distribution;
+        $search [] = '#LINK#';
+        $replace[] = $downloadLink;
+
+        $message = str_replace($search, $replace, $tpl);
+        $subject = events::_extractHeader('subject', $message);
+        $to      = events::_extractHeader('to', $message);
+        $bcc     = events::_extractHeader('bcc', $message);
+
+        $extraHeaders = events::_getDefaultExtraHeaders();
+        $extraHeaders[] = 'X-DEHS-UVERSION: ' . $newVersion;
+        $extraHeaders[] = 'BCC: ' . $bcc;
+
+        if (!mail($to, $subject, $message, implode("\r\n", $extraHeaders), escapeshellarg($to)))
+        return false;
+
+        events::_recordEvent(__FUNCTION__, $sourcePackage, $distribution, $newVersion);
+    }
+
+    function _extractHeader($header, &$message)
+    {
+        $regex  = '/' . preg_quote($header, '/') . ':([ \t]*)(.*)/i';
+
+        $matches = array();
+
+        if (preg_match($regex, $message, $matches)) {
+
+            $spacer = $matches[1];
+            $value  = $matches[2];
+
+            $message = trim(preg_replace($regex, '', $message));
+
+            return $value;
+
+        }
+        return false;
+    }
+
+    function _getDefaultExtraHeaders()
+    {
+        global $notificationsMailFrom;
+        $headers = array();
+
+        $headers[] = 'From: ' . $notificationsMailFrom;
+//        $headers[] = 'X-PTS-Approved: sure';
+        $headers[] = 'X-BY-DEHS: sure';
+
+        return $headers;
+    }
+
+    function _recordEvent($eventType, $packageName, $distribution, $content)
+    {
+        $db = events::DB();
+
+        $eventType    = pg_escape_string($eventType);
+        $packageName  = pg_escape_string($packageName);
+        $distribution = pg_escape_string($distribution);
+        $content      = pg_escape_string($content);
+
+        pg_exec($db, "INSERT INTO events (name,type,dist,content,stamp) VALUES ('$packageName','$eventType','$distribution','$content',now())") OR die_status("Failed to record event: $packageName|$eventType|$distribution|$content");
+    }
+
+    function _searchEvent($eventType, $packageName, $contentSearch, $distribution = '')
+    {
+        $db = events::DB();
+
+        $eventType    = pg_escape_string($eventType);
+        $packageName  = pg_escape_string($packageName);
+
+        $result = pg_exec($db, "SELECT id FROM events WHERE name='$packageName' and type='$eventType' ".($distribution? "and dist='$distribution'":'')." and content LIKE '$contentSearch'");
+        return pg_fetch_all($result);
+    }
+
+}
+
+?>
\ No newline at end of file

Modified: trunk/www/maintainer.php
===================================================================
--- trunk/www/maintainer.php	2008-03-20 05:02:15 UTC (rev 121)
+++ trunk/www/maintainer.php	2008-03-24 17:45:37 UTC (rev 122)
@@ -55,18 +55,18 @@
 $maint = pg_escape_string($maint);
 $name  = pg_escape_string($name);
 
-$sql=ARRAY(no_watch=>"SELECT id,mpop_inst,name,pkgs.version,pkgs.dist,tot_up_error, tot_avg_error_date,wwiz,wwiz_type,wwiz_version,maint,section,up_changes,up_url,dversionmangled,lastupvsdebsync,lastcheck FROM pkgs INNER JOIN
-(Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist HAVING max(pop_inst) IS NOT NULL) as binpkgs using(name,dist)
-WHERE (watch IS NULL OR watch='') AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' ORDER BY mpop_inst DESC;",
-no_upstream=>"select id,mpop_inst,name,section,version, tot_up_error, tot_avg_error_date, pkgs.dist,watch_warn,up_changes, up_version,up_url,dversionmangled,lastupvsdebsync,lastcheck  from pkgs INNER JOIN (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist)
-as binpkgs using(name,dist) where up_version='' AND watch!='' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' order by mpop_inst desc;",
-no_updated=>"Select id,mpop_inst,name,section,version,tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,up_url,dversionmangled,lastupvsdebsync,lastcheck from pkgs
-INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
+$sql=ARRAY(no_watch=>"SELECT id,pkgs.pop_inst,name,pkgs.version,pkgs.dist,tot_up_error, tot_avg_error_date,wwiz,wwiz_type,wwiz_version,maint,section,up_changes,up_url,dversionmangled,lastupvsdebsync,lastcheck FROM pkgs INNER JOIN
+(Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
+WHERE (watch IS NULL OR watch='') AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' ORDER BY pop_inst DESC;",
+no_upstream=>"select id,pkgs.pop_inst,name,section,version, tot_up_error, tot_avg_error_date, pkgs.dist,watch_warn,up_changes, up_version,up_url,dversionmangled,lastupvsdebsync,lastcheck  from pkgs INNER JOIN (Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist)
+as binpkgs using(name,dist) where up_version='' AND watch!='' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' order by pop_inst desc;",
+no_updated=>"Select id,pkgs.pop_inst,name,section,version,tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,up_url,dversionmangled,lastupvsdebsync,lastcheck from pkgs
+INNER join (Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
 where updated='0' AND up_version!='' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name'
-order by mpop_inst desc;",ok=>"Select id,mpop_inst,name,section,version,tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,up_url,dversionmangled,lastupvsdebsync,lastcheck from pkgs
-INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
+order by pop_inst desc;",ok=>"Select id,pkgs.pop_inst,name,section,version,tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,up_url,dversionmangled,lastupvsdebsync,lastcheck from pkgs
+INNER join (Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
 where updated='1' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' AND (up_version != '' AND up_version IS NOT NULL)
-order by mpop_inst desc;");
+order by pop_inst desc;");
 foreach($sql as $key => $value) {
 	$rs=pg_exec($db,$value) OR Die("Error on query");
 	$qta=pg_exec($db, "SELECT count(name) from pkgs WHERE (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' ") OR Die("Errore on query");
@@ -115,7 +115,7 @@
 <ul>
 <li><a name="<? print $res_array["name"]; ?>"><b>Name:</b> <a href="http://packages.qa.debian.org/<?=$res_array['name']?>"><? print $res_array["name"]; ?></a></a></li>
 <ul>
-<li><b>Pop Inst:</b> <a href="http://qa.debian.org/popcon.php?package=<?=$res_array['name']?>"><? print $res_array["mpop_inst"]; ?></a></li>
+<li><b>Pop Inst:</b> <a href="http://qa.debian.org/popcon.php?package=<?=$res_array['name']?>"><? print $res_array["pop_inst"]; ?></a></li>
 <? if ($key=="no_watch") { ?>
 <li><b>WWiz Upstream Version:</b>
 		    <? if ($res_array["wwiz_version"]) {?>

Modified: trunk/www/no_updated.php
===================================================================
--- trunk/www/no_updated.php	2008-03-20 05:02:15 UTC (rev 121)
+++ trunk/www/no_updated.php	2008-03-24 17:45:37 UTC (rev 122)
@@ -33,10 +33,10 @@
 <?
 require("config_www.inc");
 $rsql=pg_exec($db,
-"Select id,mpop_inst,name,version,bytes, tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,dversionmangled from pkgs
-INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
+"Select id,pkgs.pop_inst,name,version,bytes, tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,dversionmangled from pkgs
+INNER join (Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
 where updated='0' AND up_version!=''
-order by mpop_inst desc;") OR Die("Error on query");;
+order by pop_inst desc;") OR Die("Error on query");;
 $rsql2=pg_exec($db, "SELECT count(name) from pkgs WHERE up_version IS NOT NULL") OR Die("Errore on query");
 $totnowatch=pg_numrows($rsql);
 $totpkgs=pg_fetch_array($rsql2,0);
@@ -63,7 +63,7 @@
         	while ($res_array=pg_fetch_array($rsql)) {
 ?>
     <tr>
-      <td style="vertical-align: top;"><? print $res_array["mpop_inst"]; ?><br>
+      <td style="vertical-align: top;"><? print $res_array["pop_inst"]; ?><br>
       </td>
       <td style="vertical-align: top;"><? print $res_array["name"]; ?><br>
       </td>

Modified: trunk/www/no_upstream.php
===================================================================
--- trunk/www/no_upstream.php	2008-03-20 05:02:15 UTC (rev 121)
+++ trunk/www/no_upstream.php	2008-03-24 17:45:37 UTC (rev 122)
@@ -14,7 +14,7 @@
 <?include("menu.inc");?>
 <?
 require "config_www.inc";
-$rsql=pg_exec($db, "select mpop_inst,name,tot_up_error, tot_avg_error_date, pkgs.dist,watch_warn  from pkgs INNER JOIN (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist) where up_version='' AND watch!='' order by mpop_inst desc;");
+$rsql=pg_exec($db, "select pkgs.pop_inst,name,tot_up_error, tot_avg_error_date, pkgs.dist,watch_warn  from pkgs INNER JOIN (Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist) where up_version='' AND watch!='' order by pop_inst desc;");
 $rsql2=pg_exec($db, "SELECT count(name) from pkgs WHERE watch is not null");
 $totnowatch=pg_numrows($rsql);
 $totpkgs=pg_fetch_array($rsql2);
@@ -44,7 +44,7 @@
         	while ($res_array=pg_fetch_array($rsql)) {
 ?>
     <tr>
-      <td style="vertical-align: top;"><? print $res_array["mpop_inst"]; ?><br>
+      <td style="vertical-align: top;"><? print $res_array["pop_inst"]; ?><br>
       </td>
       <td style="vertical-align: top;"><? print $res_array["name"]; ?><br>
       </td>

Modified: trunk/www/no_watch.php
===================================================================
--- trunk/www/no_watch.php	2008-03-20 05:02:15 UTC (rev 121)
+++ trunk/www/no_watch.php	2008-03-24 17:45:37 UTC (rev 122)
@@ -31,9 +31,9 @@
 Source packages that need watch files - Sorted by popularity<br><br>
 <?include("menu.inc");?>
  <?
- $sqlstring="SELECT id,mpop_inst,name,pkgs.version,pkgs.dist,tot_up_error, bytes, tot_avg_error_date,wwiz,wwiz_type,wwiz_version,up_changes FROM pkgs INNER JOIN
-(Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist HAVING max(pop_inst) IS NOT NULL) as binpkgs using(name,dist)
-WHERE watch IS NULL OR watch=''  ORDER BY mpop_inst DESC";
+ $sqlstring="SELECT id,pkgs.pop_inst,name,pkgs.version,pkgs.dist,tot_up_error, bytes, tot_avg_error_date,wwiz,wwiz_type,wwiz_version,up_changes FROM pkgs INNER JOIN
+(Select SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
+WHERE watch IS NULL OR watch=''  ORDER BY pop_inst DESC";
 require "config_www.inc";
 $rsql=pg_exec($db, $sqlstring);
 $rsql2=pg_exec($db, "SELECT count(name) from pkgs");
@@ -81,7 +81,7 @@
 	while ($res_array=pg_fetch_array($rsql)) {
 ?>
 <tr>
-<td><? print $res_array["mpop_inst"]; ?><br></td>
+<td><? print $res_array["pop_inst"]; ?><br></td>
 <td><? print $res_array["name"]; ?><br></td>
 <td>
 <? if ($res_array[up_changes]!='' AND is_updated($res_array["wwiz_version"],$res_array["version"])) { ?>




More information about the Dehs-devel mailing list