[Bps-public-commit] RT-Extension-MergeUsers branch, master, updated. 0.08-11-ga07d026

Alex Vandiver alexmv at bestpractical.com
Mon Jun 10 17:57:56 EDT 2013


The branch, master has been updated
       via  a07d0262f0fc940d6e96374fbc5d7be249e40fef (commit)
       via  a31fadcc49d524c726b3a5d7e1692469840a6726 (commit)
      from  20fbf53cfb4655cb08d9c2cf7d13c34d5df49b76 (commit)

Summary of changes:
 lib/RT/Extension/MergeUsers.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

- Log -----------------------------------------------------------------
commit a31fadcc49d524c726b3a5d7e1692469840a6726
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jun 10 17:54:31 2013 -0400

    Ensure that ->GotoFirstItem clears the list of "seen" items
    
    Failure to do so would cause the following to fail:
        my $id = $users->First->id;
        $users->GotoFirstItem;
        is( $id, $users->First->id );
    
    ...as the firt user would have been marked "already seen" and thus would
    be ignored on successive iterations through the collection.

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index 290cc72..7799bf8 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -333,7 +333,12 @@ sub Next {
     return $self->Next() if ($self->{seen_users}->{$user->id}++);
 
     return $user;
+}
 
+sub GotoFirstItem {
+    my $self = shift;
+    $self->{seen_users} = undef;
+    $self->GotoItem(0);
 }
 
 =head1 AUTHOR

commit a07d0262f0fc940d6e96374fbc5d7be249e40fef
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jun 10 17:56:29 2013 -0400

    Ensure that ->Count on a fetched collection returns the same number of items ->Next will see

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index 7799bf8..10c837b 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -341,6 +341,16 @@ sub GotoFirstItem {
     $self->GotoItem(0);
 }
 
+sub _RecordCount {
+    my $self = shift;
+    return 0 unless defined $self->{'items'};
+
+    my %seen;
+    $seen{$_->id}++ for @{ $self->{'items'} };
+    return scalar keys %seen;
+}
+
+
 =head1 AUTHOR
 
 Alex Vandiver E<lt>alexmv at bestpractical.comE<gt>

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list