--- db/prgsrc/updatedb.pl 2000/10/18 01:52:16 1.5 +++ db/prgsrc/updatedb.pl 2000/10/18 02:01:19 1.6 @@ -22,7 +22,7 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.5 2000/10/18 01:52:16 boris Exp $ +=head1 $Id: updatedb.pl,v 1.6 2000/10/18 02:01:19 boris Exp $ =cut @@ -78,7 +78,7 @@ sub getField { } next if (/^\s*$/); - if (/^(.*):\s*$/ && !$key) { + if (/^(.*)[:\.]\s*$/ && !$key) { $key = $1; next; } @@ -139,14 +139,13 @@ MAIN: $d[1]++; $d[0]+=1900; my ($CreatedAt) = $dbh->quote( join('-', @d)); - print STDERR "File created on: $CreatedAt\n"; - + open INFD, $source or die "Can't open input file: $!\n"; $source =~ s/^.*\/([^\/]*)$/$1/; $source = $dbh->quote($source); - print STDERR "Processing file: $source \n"; + print STDERR "Файл: $source, дата: $CreatedAt "; while (($key, $value) = getField(\*INFD, $dbh)) { last if (!$key); @@ -160,7 +159,7 @@ MAIN: $ParentId = ($sth->fetchrow)[0]; next; } - if ($key =~ /Чемпионат/) { + if ($key =~ /Чемпионат/ || $key =~ /Пакет/) { $ParentId = &SelectGroup($dbh, $value) unless ($ParentId); $sth = $dbh->prepare("INSERT INTO Tournaments @@ -204,32 +203,59 @@ MAIN: $all_qnum++; 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 ($TourId) { @@ -237,14 +263,21 @@ MAIN: } else { &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 WHERE Id=$TourId"); $dbh->do("UPDATE Tournaments SET QuestionsNum=$all_qnum WHERE Id=$TournamentId"); &UpdateParents($dbh, $ParentId, $all_qnum); - print STDERR "Total number of questions: $all_qnum \n"; + print STDERR "Всего вопросов: $all_qnum \n"; } $dbh->disconnect; }