Diff for /db/prgsrc/updatedb.pl between versions 1.5 and 1.6

version 1.5, 2000/10/18 01:52:16 version 1.6, 2000/10/18 02:01:19
Line 78  sub getField { Line 78  sub getField {
         }          }
         next if (/^\s*$/);          next if (/^\s*$/);
                   
         if (/^(.*):\s*$/ && !$key) {          if (/^(.*)[:\.]\s*$/ && !$key) {
             $key = $1;              $key = $1;
             next;              next;
         }          }
Line 139  MAIN: Line 139  MAIN:
         $d[1]++;          $d[1]++;
         $d[0]+=1900;          $d[0]+=1900;
         my ($CreatedAt) = $dbh->quote( join('-', @d));          my ($CreatedAt) = $dbh->quote( join('-', @d));
         print STDERR "File created on: $CreatedAt\n";  
           
         open INFD, $source           open INFD, $source 
             or die "Can't open input file: $!\n";              or die "Can't open input file: $!\n";
                   
         $source =~ s/^.*\/([^\/]*)$/$1/;          $source =~ s/^.*\/([^\/]*)$/$1/;
         $source = $dbh->quote($source);          $source = $dbh->quote($source);
         print STDERR "Processing file: $source \n";          print STDERR "Файл: $source, дата: $CreatedAt ";
                   
         while (($key, $value) = getField(\*INFD, $dbh)) {          while (($key, $value) = getField(\*INFD, $dbh)) {
             last if (!$key);              last if (!$key);
Line 160  MAIN: Line 159  MAIN:
                 $ParentId = ($sth->fetchrow)[0];                  $ParentId = ($sth->fetchrow)[0];
                 next;                  next;
             }              }
             if ($key =~ /Чемпионат/) {              if ($key =~ /Чемпионат/ || $key =~ /Пакет/) {
                 $ParentId = &SelectGroup($dbh, $value)                  $ParentId = &SelectGroup($dbh, $value)
                     unless ($ParentId);                      unless ($ParentId);
                 $sth = $dbh->prepare("INSERT INTO Tournaments                  $sth = $dbh->prepare("INSERT INTO Tournaments
Line 204  MAIN: Line 203  MAIN:
                 $all_qnum++;                  $all_qnum++;
                 next;                  next;
             }              }
             &UpdateQuestion($dbh, $QuestionId, "Answer", $value)   
                 if ($key =~ /Ответ/);              if ($key =~ /Ответ/) {
                   &UpdateQuestion($dbh, $QuestionId, "Answer", $value);
                   next;
               }
                           
             &UpdateQuestion($dbh, $QuestionId, "Authors", $value)   
                 if ($key =~ /Автор/);              if ($key =~ /Автор/) {
                   &UpdateQuestion($dbh, $QuestionId, "Authors", $value);
                   next;
               }
                           
             &UpdateQuestion($dbh, $QuestionId, "Sources", $value)   
                 if ($key =~ /Источник/);              if ($key =~ /Источник/) {
                   &UpdateQuestion($dbh, $QuestionId, "Sources", $value);
                   next;
               }
                           
             &UpdateQuestion($dbh, $QuestionId, "Comments", $value)   
                 if ($key =~ /Комментарий/);              if ($key =~ /Комментари/) {
                   &UpdateQuestion($dbh, $QuestionId, "Comments", $value);
                   next;
               }
                           
             &UpdateTournament($dbh, $TournamentId, "URL", $value)  
                 if ($key =~ /URL/);              if ($key =~ /URL/ || key =~ /Ссылка/) {
                   &UpdateTournament($dbh, $TournamentId, "URL", $value);
                   next;
               }
                           
             &UpdateTournament($dbh, $TournamentId, "Copyright", $value)  
                 if ($key =~ /Копирайт/);              if ($key =~ /Копирайт/) {
                   &UpdateTournament($dbh, $TournamentId, "Copyright", $value);
                   next;
               }
                           
             &UpdateTournament($dbh, $TournamentId, "Info", $value)  
                 if ($key =~ /Инфо/);              if ($key =~ /Инфо/) {
                   &UpdateTournament($dbh, $TournamentId, "Info", $value);
                   next;
               }
                           
             &UpdateTournament($dbh, $TournamentId, "Editors", $value)  
                 if ($key =~ /Редактор/);              if ($key =~ /Редактор/) {
                   &UpdateTournament($dbh, $TournamentId, "Editors", $value);
                   next;
               }
                           
             &UpdateTournament($dbh, $TournamentId, "EnteredBy", $value)  
                 if ($key =~ /Обработан/);              if ($key =~ /Обработан/) {
                   &UpdateTournament($dbh, $TournamentId, "EnteredBy", $value);
                   next;
                                 }
                           
             if ($key =~ /Дата/) {              if ($key =~ /Дата/) {
                 if ($TourId) {                  if ($TourId) {
Line 237  MAIN: Line 263  MAIN:
                 } else {                  } else {
                     &UpdateTournament($dbh, $TournamentId, "PlayedAt", $value);                      &UpdateTournament($dbh, $TournamentId, "PlayedAt", $value);
                 }                  }
                   next;
             }              }
               
               #
               # If we are here, something got wrong!
               #
               print STDERR "\nЯ НЕ ПОНИМАЮ: $key, $value!\n";
               
         }          }
         $dbh->do("UPDATE Tournaments SET QuestionsNum=$qnum          $dbh->do("UPDATE Tournaments SET QuestionsNum=$qnum
                         WHERE Id=$TourId");                          WHERE Id=$TourId");
         $dbh->do("UPDATE Tournaments SET QuestionsNum=$all_qnum          $dbh->do("UPDATE Tournaments SET QuestionsNum=$all_qnum
                         WHERE Id=$TournamentId");                          WHERE Id=$TournamentId");
         &UpdateParents($dbh, $ParentId, $all_qnum);                       &UpdateParents($dbh, $ParentId, $all_qnum);             
         print STDERR "Total number of questions: $all_qnum \n";          print STDERR "Всего вопросов: $all_qnum \n";
     }      }
     $dbh->disconnect;      $dbh->disconnect;
 }  }

Removed from v.1.5  
changed lines
  Added in v.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>