[Bps-public-commit] r9714 - in Net-Hiveminder: lib/Net

sartak at bestpractical.com sartak at bestpractical.com
Tue Nov 20 20:09:24 EST 2007


Author: sartak
Date: Tue Nov 20 20:09:20 2007
New Revision: 9714

Modified:
   Net-Hiveminder/   (props changed)
   Net-Hiveminder/lib/Net/Hiveminder.pm

Log:
 r45450 at onn:  sartak | 2007-11-20 20:09:12 -0500
 Move load_date to Net::Jifty
 Add for/by indications


Modified: Net-Hiveminder/lib/Net/Hiveminder.pm
==============================================================================
--- Net-Hiveminder/lib/Net/Hiveminder.pm	(original)
+++ Net-Hiveminder/lib/Net/Hiveminder.pm	Tue Nov 20 20:09:20 2007
@@ -3,7 +3,6 @@
 use Moose;
 extends 'Net::Jifty';
 
-use DateTime;
 use Number::RecordLocator;
 my $LOCATOR = Number::RecordLocator->new;
 
@@ -61,6 +60,7 @@
     my @out;
 
     my $now = DateTime->now;
+    my %email_of;
 
     for my $task (@_) {
         my $locator = $LOCATOR->encode($task->{id});
@@ -77,6 +77,25 @@
                 if $task->{$field};
         }
 
+        my $helper = sub {
+            my ($field, $name) = @_;
+
+            my $id = $task->{$field}
+                or return;
+
+            # this wants to be //=. oh well
+            my $email = $email_of{$id} ||= $self->email_of($id)
+                or return;
+
+            $self->is_me($email)
+                and return;
+
+            $display .= " [$name: $email]";
+        };
+
+        $helper->('requestor_id', 'for');
+        $helper->('owner_id', 'by');
+
         push @out, $display;
     }
 
@@ -188,28 +207,18 @@
     return $self->delete(Task => id => $id);
 }
 
-=head2 load_date Date
+=head2 email_of id
 
-Loads a yyyy-mm-dd date into a L<DateTime> object.
+Take a user ID and retrieve that user's email address.
 
 =cut
 
-sub load_date {
+sub email_of {
     my $self = shift;
-    my $ymd  = shift;
-
-    # XXX: remove me when HM is pulled live and gets the Jifty REST changes
-    $ymd =~ s/ 00:00:00$//;
+    my $id = shift;
 
-    my ($y, $m, $d) = $ymd =~ /^(\d\d\d\d)-(\d\d)-(\d\d)$/
-        or confess "Invalid date passed to load_date: $ymd. Expected yyyy-mm-dd.";
-
-    return DateTime->new(
-        time_zone => 'floating',
-        year      => $y,
-        month     => $m,
-        day       => $d,
-    );
+    my $user = $self->read(User => id => $id);
+    return $user->{email};
 }
 
 =head1 SEE ALSO



More information about the Bps-public-commit mailing list