Skip Menu |

This queue is for tickets about the Net-Hiveminder CPAN distribution.

Report information
The Basics
Id: 38177
Status: open
Priority: 0/
Queue: Net-Hiveminder

People
Owner: Nobody in particular
Requestors: nathan.vonnahme [...] bannerhealth.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: patch: add TaskTransaction accessor
Date: Mon, 4 Aug 2008 15:01:14 -0800
To: <bugs-Net-Hiveminder [...] rt.cpan.org>
From: "Vonnahme, Nathan" <nathan.vonnahme [...] bannerhealth.com>
I've added an accessor for the TaskTransaction model so I can get at a task's "last modified" datestamp. I made a stupid demo script to make sure it works-- it's not a real test script though; I suppose a real one would use data fixtures/stubs instead of actually connecting to Hiveminder. Pardon the use of Date::Manip-- if you have a more favorite module, go for it! -n =head2 get_task_history LOCATOR Load the transaction history for task LOCATOR. Returns an array of transactions looking like: $VAR1 = { 'modified_at' => '2008-07-24 15:38:06', 'type' => 'update', 'id' => '1745040', 'task_id' => '433397', 'created_by' => '463' }; =cut sub get_task_history { my $self = shift; my $task_id = $self->loc2id(shift); # see http://hiveminder.com/=/model/BTDT.Model.TaskTransaction return $self->search( 'TaskTransaction', task_id => $task_id, ); } =head2 get_task_last_modified LOCATOR Look up the date/time of the last modification to task LOCATOR. $lastmod = $hm->get_task_history('GACK'); # '2008-07-24 15:38:06' This method requires L<Date::Manip>, which is an optional dependency of Net::Hiveminder. If Date::Manip is unavailable, then this will throw an error. B<WARNING:> This is kind of slow. =cut sub get_task_last_modified { my $self = shift; my $locator = shift; require Date::Manip; # get all the transactions my $transactions = $self->get_task_history($locator); # explicitly sort chronologically @$transactions = sort {Date::Manip::Date_Cmp($a->{modified_at}, $b->{modified_at})} @$transactions; return $transactions->[$#$transactions]{modified_at}; } -- Nathan Vonnahme, IT Software Engineer at Fairbanks Memorial Hospital nathan.vonnahme@bannerhealth.com 907-458-5464 1650 Cowles St, Fairbanks, Alaska 99701

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Hi Nathan, Thanks for your nearly-year-old patch. I added get_task_history to Net::Hiveminder. I didn't add get_task_last_modified yet because I think it should use DateTime. I'll see about writing it. Thanks! Shawn
Subject: RE: [rt.cpan.org #38177] patch: add TaskTransaction accessor
Date: Mon, 13 Jul 2009 11:44:04 -0800
To: <bug-Net-Hiveminder [...] rt.cpan.org>
From: "Vonnahme, Nathan" <nathan.vonnahme [...] bannerhealth.com>
Yay! Show quoted text
> -----Original Message----- > From: Shawn M Moore via RT [mailto:bug-Net-Hiveminder@rt.cpan.org] > Sent: Thursday, July 09, 2009 12:35 AM > To: Vonnahme, Nathan > Subject: [rt.cpan.org #38177] patch: add TaskTransaction accessor > > <URL: https://rt.cpan.org/Ticket/Display.html?id=38177 > > > Hi Nathan, > > Thanks for your nearly-year-old patch. I added get_task_history to > Net::Hiveminder. I didn't add get_task_last_modified yet because I > think > it should use DateTime. I'll see about writing it. > > Thanks! > > Shawn