[Cpan-forum-commit] rev 326 - in trunk: . lib/CPAN lib/CPAN/Forum/DB
svn at pti.co.il
svn at pti.co.il
Fri Aug 10 18:33:57 EEST 2007
Author: gabor
Date: 2007-08-10 18:33:57 +0300 (Fri, 10 Aug 2007)
New Revision: 326
Modified:
trunk/
trunk/lib/CPAN/Forum.pm
trunk/lib/CPAN/Forum/DB/Subscriptions.pm
Log:
refactor the fetching the subscriptions before the mail sending to use the
get_subscription method
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4394
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
+ 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4395
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
Modified: trunk/lib/CPAN/Forum/DB/Subscriptions.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Subscriptions.pm 2007-08-10 15:33:39 UTC (rev 325)
+++ trunk/lib/CPAN/Forum/DB/Subscriptions.pm 2007-08-10 15:33:57 UTC (rev 326)
@@ -49,22 +49,26 @@
Carp::croak("Invalid field '$field'");
}
- my $sql = " SELECT DISTINCT username
+ # People who asked for all the posts
+ # People who asked for all the posts in this group
+ # People who asked for all the posts in this PAUSEID
+
+ my $sql = " SELECT DISTINCT username, email
FROM users, subscriptions_all
WHERE (users.id=subscriptions_all.uid AND subscriptions_all.$field=1)
UNION
- SELECT DISTINCT username
+ SELECT DISTINCT username, email
FROM users, subscriptions
WHERE (users.id=subscriptions.uid AND subscriptions.$field=1 AND gid=?)
UNION
- SELECT DISTINCT username
+ SELECT DISTINCT username, email
FROM users, subscriptions_pauseid
WHERE
(users.id=subscriptions_pauseid.uid
AND subscriptions_pauseid.$field=1
AND subscriptions_pauseid.pauseid=?)
ORDER BY username";
- return $self->_select_column($sql, $gid, $pauseid);
+ return $self->_fetch_arrayref_of_hashes($sql, $gid, $pauseid);
}
1;
Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm 2007-08-10 15:33:39 UTC (rev 325)
+++ trunk/lib/CPAN/Forum.pm 2007-08-10 15:33:57 UTC (rev 326)
@@ -1387,10 +1387,10 @@
sub _subscriptions {
my ($self, $t, $group) = @_;
- my $usernames = CPAN::Forum::DB::Subscriptions->get_subscriptions('allposts', $group->{id}, $group->{pauseid}); # SQL
- my @users = map {{username => $_}} @$usernames;
+ my $users = CPAN::Forum::DB::Subscriptions->get_subscriptions('allposts', $group->{id}, $group->{pauseid}); # SQL
+ my @usernames = map {{ username => $_->{username} }} @$users;
#$self->log->debug(Data::Dumper->Dump([\@users], ['users']));
- $t->param(users => \@users);
+ $t->param(users => \@usernames);
}
sub add_new_group {
@@ -1434,20 +1434,11 @@
# subscriptions to "all" messages in the current group
$self->log->debug("Processing messages for allposts");
- my $it;
- # People who asked for all the posts
- $it = CPAN::Forum::DB::Subscriptions_all->search(allposts => 1);
- $self->_sendmail($it, $mail, \%to);
+ my $users = CPAN::Forum::DB::Subscriptions->get_subscriptions('allposts', $post->{gid}, $post->{pauseid}); # SQL
+ $self->_sendmail($users, $mail, \%to);
- # People who asked for all the posts in this group
- $it = CPAN::Forum::DB::Subscriptions->search(allposts => 1, gid => $post->{gid});
- $self->_sendmail($it, $mail, \%to);
-
- # People who asked for all the posts in this PAUSEID
- $it = CPAN::Forum::DB::Subscriptions_pauseid->search(allposts => 1, pauseid => $post->{pauseid});
- $self->_sendmail($it, $mail, \%to);
-
+ my $it;
if ($post->{thread} == $post->{id}) {
$self->log->debug("Processing messages for thread starter");
@@ -1488,14 +1479,14 @@
}
sub _sendmail {
- my ($self, $it, $mail, $to, $uids) = @_;
+ my ($self, $users, $mail, $to, $uids) = @_;
- while (my $s = $it->next) {
+ foreach my $user (@$users) {
#$self->log->debug(Data::Dumper->Dump([$mail], ['mail']));
- my $email = $s->uid->email;
+ my $email = $user->{email};
$mail->{To} = $email;
- $self->log->debug("Processing uid: " . $s->uid->username) if $uids;
- next if $uids and not $uids->{$s->uid->username};
+ $self->log->debug("Processing uid: " . $user->{username}) if $uids;
+ next if $uids and not $uids->{$user->{username}};
$self->log->debug("Sending to $email id was found");
next if $_[3]->{$email}++; #TODO: stop using hardcoded reference to position!!!!!
$self->log->debug("Sending to $email first time sending");
More information about the Cpan-forum-commit
mailing list