Join visibility into search.pm

git-svn-id: svn://10.0.0.236/branches/Groups_20020716_Branch@128975 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bugreport%peshkin.net
2002-09-06 18:08:06 +00:00
parent 0bb0108b90
commit b4223e1351
2 changed files with 20 additions and 4 deletions

View File

@@ -813,9 +813,22 @@ sub init {
$suppseen{$str} = 1;
}
}
my $query = ("SELECT DISTINCT " . join(', ', @fields) .
my $query = ("SELECT DISTINCT " .
" COUNT(ugmap.group_id) AS cntuseringroups, " .
" COUNT(bgmap.group_id) AS cntbugingroups, " .
join(', ', @fields) .
" FROM $suppstring" .
" WHERE " . join(' AND ', (@wherepart, @andlist)));
" LEFT JOIN bug_group_map AS bgmap " .
" ON bgmap.bug_id = bugs.bug_id " .
" LEFT JOIN user_group_map AS ugmap " .
" ON bgmap.group_id = ugmap.group_id " .
" AND ugmap.user_id = $::userid" .
" AND ugmap.isbless = 0" .
" WHERE " . join(' AND ', (@wherepart, @andlist)) .
" GROUP BY bugs.bug_id " .
" HAVING cntuseringroups = cntbugingroups" .
" "
);
if ($debug) {
print "<p><code>" . value_quote($query) . "</code></p>\n";

View File

@@ -211,9 +211,9 @@ sub GetGroupsByUserId {
SendSQL("
SELECT groups.id, name, description, isactive
FROM groups, user_group_map
WHERE user_id = $userid AND isbless = 0
WHERE user_id = $userid AND NOT isbless
AND user_group_map.group_id = groups.id
AND isbuggroup = 1
AND isbuggroup
ORDER BY description ");
my @groups;
@@ -606,6 +606,9 @@ my @bugs; # the list of records
while (my @row = FetchSQLData()) {
my $bug = {}; # a record
# discard the first 2 fields - they are counters for filtering
shift @row;
shift @row;
# Slurp the row of data into the record.
foreach my $column (@selectcolumns) {