[Debtags-commits] [svn] r1502 -
central-database/branches/alioth/webfrontend
Enrico Zini
enrico at costa.debian.org
Tue Nov 15 16:02:06 UTC 2005
Author: enrico
Date: Tue Nov 15 16:02:05 2005
New Revision: 1502
Modified:
central-database/branches/alioth/webfrontend/Engine.pm
Log:
Optimized the initial wanted tag selection
Modified: central-database/branches/alioth/webfrontend/Engine.pm
==============================================================================
--- central-database/branches/alioth/webfrontend/Engine.pm (original)
+++ central-database/branches/alioth/webfrontend/Engine.pm Tue Nov 15 16:02:05 2005
@@ -811,12 +811,47 @@
# {
# &main::msg("%d: %s\n", $tags{$tag}, $tag);
# }
- while (scalar(findPackages({tags => [tags(@res)], notags => $search->{notags}})) < 4)
+
+ # Count how many packages would match the sets of @res[0 .. X], per all
+ # possible X
+ my @occ;
+ for my $p (findPackages({ tags => [tags($res[0])], notags => $search->{notags} }))
+ {
+ my %ts = map { $_->name => 1 } $p->tags();
+ my $count;
+ for ($count = 0; defined($res[$count]) && $count < @res; $count++)
+ {
+ last if not exists $ts{$res[$count]};
+ }
+ ++$occ[$count];
+ }
+ # Choose the best X
+
+ # First thing, aggregate the counts
+ for (my $i = $#occ; $i > 0; $i--)
{
-# &main::msg("No entries with %s, trying to remove %s\n", join(',', at res), $res[$#res]);
- pop @res;
+ $occ[$i - 1] += $occ[$i];
}
- return @res;
+
+ # Then pick a good count
+ my $amount;
+ for (my $i = 0; $i < @occ; $i++)
+ {
+ if ($occ[$i] < 4)
+ {
+ $amount = ($i == 0) ? 0 : ($i - 1);
+ last;
+ }
+ }
+
+ return @res[0 .. $amount];
+
+# while (scalar(findPackages({tags => [tags(@res)], notags => $search->{notags}})) < 4)
+# {
+## &main::msg("No entries with %s, trying to remove %s\n", join(',', at res), $res[$#res]);
+# pop @res;
+# }
+# return @res;
}
##
More information about the Debtags-commits
mailing list