[Debian-l10n-commits] r1594 - in /dl10n/trunk: Changelog lib/Debian/L10n/BTS.pm lib/Debian/L10n/Spider.pm

nekral-guest at users.alioth.debian.org nekral-guest at users.alioth.debian.org
Sun Feb 15 16:53:28 UTC 2009


Author: nekral-guest
Date: Sun Feb 15 16:53:27 2009
New Revision: 1594

URL: http://svn.debian.org/wsvn/?sc=1&rev=1594
Log:
	* lib/Debian/L10n/BTS.pm, lib/Debian/L10n/Spider.pm: Do not
	overload the BTS soap interface. Prepare the list of bugs we need
	to check, and then check all the bugs at the same time. Thanks to
	Don Armstrong. check_bts_bug_soap() renamed check_bts_bugs_soap().
	The function does not return any status anymore.

Modified:
    dl10n/trunk/Changelog
    dl10n/trunk/lib/Debian/L10n/BTS.pm
    dl10n/trunk/lib/Debian/L10n/Spider.pm

Modified: dl10n/trunk/Changelog
URL: http://svn.debian.org/wsvn/dl10n/trunk/Changelog?rev=1594&op=diff
==============================================================================
--- dl10n/trunk/Changelog (original)
+++ dl10n/trunk/Changelog Sun Feb 15 16:53:27 2009
@@ -1,3 +1,11 @@
+2008-01-15  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* lib/Debian/L10n/BTS.pm, lib/Debian/L10n/Spider.pm: Do not
+	overload the BTS soap interface. Prepare the list of bugs we need
+	to check, and then check all the bugs at the same time. Thanks to
+	Don Armstrong. check_bts_bug_soap() renamed check_bts_bugs_soap().
+	The function does not return any status anymore.
+
 2008-12-06  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* pootle/sync-projects.d/20di: Execute with "set -e".

Modified: dl10n/trunk/lib/Debian/L10n/BTS.pm
URL: http://svn.debian.org/wsvn/dl10n/trunk/lib/Debian/L10n/BTS.pm?rev=1594&op=diff
==============================================================================
--- dl10n/trunk/lib/Debian/L10n/BTS.pm (original)
+++ dl10n/trunk/lib/Debian/L10n/BTS.pm Sun Feb 15 16:53:27 2009
@@ -58,7 +58,8 @@
 sub check_bts_soap($$) {
 	my $db = shift;
 	my $dbName = shift;
-	my $count = 0;
+
+	my @bugs_to_check;
 
 	foreach my $pkg (sort (grep { $db->has_status($_) } $db->list_packages())) {
 		# Only check a bug if the last status for a file/type is BTS
@@ -79,44 +80,58 @@
 				next	unless    ($status_from_db eq 'bts')
 				               || ($status_from_db eq 'wontfix')
 				               || ($status_from_db eq 'fix');
-				check_bts_bug_soap ($db, $pkg, $statusline);
-				# Note: this will only add the DONE tags
-				#       if bugs are now closed.
-				#       There is no need to parse these
-				#       additional statusline.
-				$count++;
-				if ($count > 10) {
-					$count = 0;
-					$db->write($dbName) if defined $dbName;
-				}
+				push @bugs_to_check, ($pkg, $statusline);
 			}
 		}
 	}
-}
-
-sub check_bts_bug_soap ($$$) {
-	my $db = shift;
-	my $pkg = shift;
-	my $statusline = shift;
+
+	check_bts_bugs_soap ($db, $dbName, @bugs_to_check);
+}
+
+sub check_bts_bugs_soap ($$@) {
+	my ($db, $dbName, @bugs_to_check) = @_;
+
+	# Get the list of bugs
+	my $i = 0;
+	my %bugs;
+	while ( $i < $#bugs_to_check ) {
+		my ($type, $file, $date, $status_from_db, $translator, $list, $url, $bug_nb) = @{$bugs_to_check[$i+1]};
+		$bugs{$bug_nb} = 1;
+		$i+=2;
+	}
+
+	# Query the BTS
+	my $soap_bugs = $soap->get_status([keys %bugs])->result();
+	if (not defined $soap_bugs or not length $soap_bugs) {
+		warn "Failed to query the BTS\n";
+		return 0;
+	}
+
+	# Now we can Update the database
+	my $count = 0;
+	while (@bugs_to_check) {
+		my $pkg = shift @bugs_to_check;
+		my $statusline = shift @bugs_to_check;
 	my $changed = 0; # 0: No changes
 	                 # 1: Updated
 	                 # 2: New status added
 	my ($type, $file, $date, $status_from_db, $translator, $list, $url, $bug_nb) = @{$statusline};
 	my $bugwontfix = 0;
 
+	# Make sure the database is written from time to time
+	if ($count > 10) {
+		$count = 0;
+		$db->write($dbName) if defined $dbName;
+	}
+
 	unless ($seen{$bug_nb}) {
 		my $bugdone = 0;
 		my $content;
-		my $soap_bugs = $soap->get_status($bug_nb)->result();
-		if (not defined $soap_bugs or not length $soap_bugs) {
-			warn "Cannot find bug '$bug_nb' ($pkg: $type#$file)\n";
-			return 0;
-		}
 
 		my $pkg_bug = $soap_bugs->{$bug_nb}->{package};
 		if (    ($pkg_bug ne $pkg)
 		    and ($pkg_bug ne "wnpp")) {
-			print STDERR "Warning: #$bug_nb filled against $pkg_bug but $pkg is in the database\n";
+			warn "Warning: #$bug_nb filled against $pkg_bug but $pkg is in the database\n";
 		}
 		$opendate{$bug_nb} = Date::Format::time2str("%Y-%m-%d %T %z", $soap_bugs->{$bug_nb}->{date}, "GMT");
 		$bugsubmitter{$bug_nb} = parse_submitter($soap_bugs->{$bug_nb}->{originator});
@@ -186,8 +201,8 @@
 	} elsif ($changed == 1) {
 		$db->set_status($pkg, $type, $file, $date, $status_from_db, $translator, $list, $url, $bug_nb, $statusline);
 	}
-
-	return $changed;
+	}
+
 }
 
 =head1 LICENSE

Modified: dl10n/trunk/lib/Debian/L10n/Spider.pm
URL: http://svn.debian.org/wsvn/dl10n/trunk/lib/Debian/L10n/Spider.pm?rev=1594&op=diff
==============================================================================
--- dl10n/trunk/lib/Debian/L10n/Spider.pm (original)
+++ dl10n/trunk/lib/Debian/L10n/Spider.pm Sun Feb 15 16:53:27 2009
@@ -306,12 +306,6 @@
 					$db->add_status($pkg, $type, $file, $date, $status, $translator, $list, $url, ($bug_nb || ""));
 					print "Insert $pkg: $type#$file#$date#$status#$translator#$list#$url#".($bug_nb ? "$bug_nb" : "")."\n";
 
-					if ($check_bts and $status eq 'bts') {
-						# Check the status of the bug with the last status line.
-						# This will set the bug to status to DONE if the bug is an old one.
-						my @statuslist = @{$db->status($pkg)};
-						Debian::L10n::BTS::check_bts_bug_soap ($db, $pkg, pop @statuslist);
-					}
 				}
 			} continue {
 				$db->set_header('Year',    $year   );




More information about the Debian-l10n-commits mailing list