/[dehs]/trunk/dehs_pg.php
ViewVC logotype

Diff of /trunk/dehs_pg.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 77 by atomo64-guest, Sun Dec 16 01:53:08 2007 UTC revision 78 by atomo64-guest, Sun Dec 16 23:37:18 2007 UTC
# Line 340  function check_db() { Line 340  function check_db() {
340          pg_exec($db, "CREATE UNIQUE INDEX idxbin on binpkgs (name,bin_name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));          pg_exec($db, "CREATE UNIQUE INDEX idxbin on binpkgs (name,bin_name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
341          $sw=true;          $sw=true;
342      }      }
343        /*if (!pg_table_exists($db,"events")){
344            pg_exec($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text)") or die_status('Error creating table binpkgs\n');
345            pg_exec($db, "CREATE UNIQUE INDEX idxevents on events (name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
346            $sw=true;
347        }*/
348      #if (!pg_table_exists($db,"upstream")){      #if (!pg_table_exists($db,"upstream")){
349      #  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 TABLE upstream (name text,dist text,up_version text,watch_warn text,updated bool)") or die_status('Errore nel creare la tabella');
350      #  pg_exec($db, "CREATE UNIQUE INDEX idxupstrm on upstream (name,dist)") or die_status('Errore nel creare gli indici ' . pg_last_error($db));      #  pg_exec($db, "CREATE UNIQUE INDEX idxupstrm on upstream (name,dist)") or die_status('Errore nel creare gli indici ' . pg_last_error($db));
# Line 402  function db_popcon($initial='') { Line 407  function db_popcon($initial='') {
407              if (preg_match($regexp,$line,$matches)) {              if (preg_match($regexp,$line,$matches)) {
408                  #print "\rName => $matches[1] Install => $matches[2] Vote => $matches[3]";                  #print "\rName => $matches[1] Install => $matches[2] Vote => $matches[3]";
409                  @pg_exec($db, "UPDATE binpkgs SET pop_inst='$matches[2]',pop_vote='$matches[3]' WHERE bin_name='$matches[1]'");                  @pg_exec($db, "UPDATE binpkgs SET pop_inst='$matches[2]',pop_vote='$matches[3]' WHERE bin_name='$matches[1]'");
410                  $prcessed++;                  /*$processed++;
411                  /*$elapsed_time=time()-$tin;                  $elapsed_time=time()-$tin;
412                  if (($elapsed_time % 20)==0 AND $updtime!=$elapsed_time) {                  if (($elapsed_time % 20)==0 AND $updtime!=$elapsed_time) {
413                      $updtime=$elapsed_time;                      $updtime=$elapsed_time;
414                      $wprocessed=$processed-$wprocessed;                      $wprocessed=$processed-$wprocessed;
# Line 420  function db_popcon($initial='') { Line 425  function db_popcon($initial='') {
425      }      }
426      @pg_close($db);      @pg_close($db);
427  }  }
 function db_popcon_test() {  
     global $dirs,$dbconn;  
     $db = pg_pconnect($dbconn)  or  die_status(pg_last_error($db));  
     $filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";  
     $regexp="/Package:\s(\S+)\s+(\d+)\s+(\d+)/";  
     $zp = gzfile($filename, "r") or die_status("Could not open $filename");  
     if(filesize($filename)>20) {  
         foreach ($zp as $line) {  
             if (preg_match($regexp,$line,$matches)) {  
                 # print "Name => $matches[1] \n Install => $matches[2] \n Vote => $matches[3]\n";  
                 print "\r" . $i++;  
                 #pg_unbuffered_query($db, "UPDATE binpkgs SET pop_inst='$matches[2]',pop_vote='$matches[3]' WHERE bin_name='$matches[1]'");  
             }  
         }  
     }  
     @pg_close($db);  
 }  
428  function dl_popcon() {  function dl_popcon() {
429      global $dirs,$dbconn;      global $dirs,$dbconn;
430      $localfile=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";      $localfile=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";
# Line 482  function db_upstream($initial='%') { Line 470  function db_upstream($initial='%') {
470          }          }
471          pg_exec($db, "UPDATE pkgs SET up_version='" . pg_escape_string($up_version) . "', dversionmangled='".pg_escape_string($dversionmangled)."',up_url='" . pg_escape_string($up_url) . "', watch_warn='" . $watch_warn . "',keep_changes='$keep_changes', wwiz_version=NULL, wwiz_type=NULL, wwiz=NULL, updated='$updated' WHERE id=$res_array[id]") or die_status("Error in update pkgs upstream");          pg_exec($db, "UPDATE pkgs SET up_version='" . pg_escape_string($up_version) . "', dversionmangled='".pg_escape_string($dversionmangled)."',up_url='" . pg_escape_string($up_url) . "', watch_warn='" . $watch_warn . "',keep_changes='$keep_changes', wwiz_version=NULL, wwiz_type=NULL, wwiz=NULL, updated='$updated' WHERE id=$res_array[id]") or die_status("Error in update pkgs upstream");
472          #print "\rUpdated " . $res_array['name'] .  " => $updated Up Version => ". $uscan_res[0];          #print "\rUpdated " . $res_array['name'] .  " => $updated Up Version => ". $uscan_res[0];
473          print "\tUpstream left => " . $tot --;          print "\t Upstream left => " . $tot --;
474          #                               }          #                               }
475          #                                                       else print "Added ". $res_array['name'] ."\n";          #                                                       else print "Added ". $res_array['name'] ."\n";
476          #       if ($great==0) {          #       if ($great==0) {
# Line 794  function watch_wizard($src_name='%'){ Line 782  function watch_wizard($src_name='%'){
782    
783                      $uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$watch);                      $uscan_res=uscan_foo($res_array['name'] ,$res_array['version'],$watch);
784    
785                      if ($uscan_res[0]) {                      if ($uscan_res[0] && levenshtein($uscan_res[0], $res_array['version']) < strlen($res_array['version'])) {
786                          break;                          break;
787                      }                      }
788                  }                  }
# Line 818  function watch_wizard($src_name='%'){ Line 806  function watch_wizard($src_name='%'){
806                          $updated=is_updated($uscan_res[0],$dversionmangled);                          $updated=is_updated($uscan_res[0],$dversionmangled);
807                      }                      }
808    
809                      if (!$updated) {                      /*if (!$updated) {
810                          events::newVersion($res_array['name'], $res_array['version'], $uscan_res[0], $res_array['dist']);                          events::newVersion($res_array['name'], $res_array['version'], $uscan_res[0], $res_array['dist']);
811                      }                      }*/
812    
813                      pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res[0]) . "',dversionmangled='".pg_escape_string($dversionmangled)."', up_url='" . pg_escape_string($uscan_res[2]) . "', keep_changes='$keep_changes', updated='$updated' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");                      pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res[0]) . "',dversionmangled='".pg_escape_string($dversionmangled)."', up_url='" . pg_escape_string($uscan_res[2]) . "', keep_changes='$keep_changes', updated='$updated' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
814                  }                  }

Legend:
Removed from v.77  
changed lines
  Added in v.78

  ViewVC Help
Powered by ViewVC 1.1.5