[Bps-public-commit] r11520 - in SVN-PropDB: . lib/Prophet/Sync/Source/RT
jesse at bestpractical.com
jesse at bestpractical.com
Fri Apr 4 21:51:47 EDT 2008
Author: jesse
Date: Fri Apr 4 21:51:47 2008
New Revision: 11520
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/lib/Prophet/Sync/Source/RT.pm
SVN-PropDB/lib/Prophet/Sync/Source/RT/PullEncoder.pm
Log:
r29214 at 68-246-40-124: jesse | 2008-04-04 15:51:40 -1000
* passing test! Need more tests! YATTA
Modified: SVN-PropDB/lib/Prophet/Sync/Source/RT.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/RT.pm (original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/RT.pm Fri Apr 4 21:51:47 2008
@@ -154,6 +154,37 @@
}
+sub ticket_uuid {
+ my ($self, $id) = @_;
+
+ my $cache = App::Cache->new( { ttl => 60 * 60 } ); # la la la
+ warn "===> ticket $id ?".$self->uuid.'-ticket-' . $id ;
+ my $uuid = $cache->get( $self->uuid.'-ticket-' . $id );
+
+ warn "=got $uuid " if $uuid;
+ return $uuid if $uuid;
+
+ return $self->uuid_for_url( $self->rt_url . "/ticket/$id" ),
+}
+
+
+
+
+sub record_pushed_ticket {
+ my $self = shift;
+ my %args= validate(@_, {uuid => 1,
+ remote_id => 1
+ });
+ my $cache = App::Cache->new( { ttl => 60 * 60 } );
+ warn "record just pushed ticket $args{remote_id} as ". $args{uuid};
+ warn $self->uuid.'-ticket-' . $args{remote_id} ;
+
+ $cache->set(
+ $self->uuid.'-ticket-' . $args{remote_id} =>
+ $args{uuid}
+ );
+}
+
sub _integrate_change {
my $self = shift;
my ( $change, $changeset ) = validate_pos( @_, { isa => 'Prophet::Change' }, { isa => 'Prophet::ChangeSet' } );
@@ -162,7 +193,11 @@
if ( $change->node_type eq 'ticket' and $change->change_type eq 'add_file' )
{
$id = $self->integrate_ticket_create( $change, $changeset );
+
+ $self->record_pushed_ticket(uuid => $change->node_uuid, remote_id => $id);
+
} elsif ( $change->node_type eq 'comment' ) {
+
$id = $self->integrate_comment( $change, $changeset );
} elsif ( $change->node_type eq 'ticket' ) {
$id = $self->integrate_ticket_update( $change, $changeset );
@@ -313,6 +348,9 @@
}
+
+
+
use Data::UUID 'NameSpace_DNS';
sub uuid_for_url {
@@ -348,6 +386,7 @@
};
}
+# warn YAML::Dump(\@changesets);
return [ sort { $a->original_sequence_no <=> $b->original_sequence_no } @changesets];
}
Modified: SVN-PropDB/lib/Prophet/Sync/Source/RT/PullEncoder.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/RT/PullEncoder.pm (original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/RT/PullEncoder.pm Fri Apr 4 21:51:47 2008
@@ -22,14 +22,17 @@
sub run {
my $self = shift;
my %args = validate( @_, { ticket => 1, transactions => 1} );
+
+ $args{'ticket'}->{'id'} =~ s/^ticket\///g;
my $ticket = $args{'ticket'};
warn "Working on " . $ticket->{id};
- my $create_state = $ticket;
+ my $create_state = $ticket;;
map { $create_state->{$_} = $self->date_to_iso( $create_state->{$_} ) }
qw(Created Resolved Told LastUpdated Starts Started);
+
map { $create_state->{$_} =~ s/ minutes$// } qw(TimeWorked TimeLeft TimeEstimated);
my @changesets;
for my $txn ( sort { $b->{'id'} <=> $a->{'id'} } @{ $args{'transactions'} } ) {
@@ -40,7 +43,7 @@
}
);
- if ( ( "ticket/" . $txn->{'Ticket'} ne $ticket->{id} ) && $txn->{'Type'} !~ /^(?:Comment|Correspond)$/ ) {
+ if ( ( $txn->{'Ticket'} ne $ticket->{id} ) && $txn->{'Type'} !~ /^(?:Comment|Correspond)$/ ) {
warn "Skipping a data change from a merged ticket" . $txn->{'Ticket'} . ' vs ' . $ticket->{id};
next;
}
@@ -87,13 +90,18 @@
return $self->_recode_txn_Set(%args);
}
+sub ticket_uuid {
+ my ($self, $id) = @_;
+ return $self->sync_source->ticket_uuid($id);
+}
+
sub _recode_txn_Set {
my $self = shift;
my %args = validate( @_, { ticket => 1, txn => 1, create_state => 1, changeset => 1 } );
my $change = Prophet::Change->new(
{ node_type => 'ticket',
- node_uuid => $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/ticket/" . $args{'create_state'}->{'id'} ),
+ node_uuid => $self->ticket_uuid($args{'create_state'}->{'id'}),
change_type => 'update_file'
}
);
@@ -141,12 +149,11 @@
my $change = Prophet::Change->new(
{ node_type => 'ticket',
- node_uuid => $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/ticket/" . $args{'create_state'}->{'id'} ),
+ node_uuid => $self->ticket_uuid($args{'create_state'}->{'id'}),
change_type => 'add_file'
}
);
- $args{'create_state'}->{'id'} =~ s/^ticket\///g;
$args{'create_state'}->{ $self->sync_source->uuid . '-id' } = delete $args{'create_state'}->{'id'};
$args{'changeset'}->add_change( { change => $change } );
@@ -176,7 +183,7 @@
my $change = Prophet::Change->new(
{ node_type => 'ticket',
- node_uuid => $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/ticket/" . $args{'create_state'}->{'id'} ),
+ node_uuid => $self->ticket_uuid($args{'create_state'}->{'id'}),
change_type => 'update_file'
}
);
@@ -241,7 +248,7 @@
my $change = Prophet::Change->new(
{ node_type => 'ticket',
- node_uuid => $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/ticket/" . $args{'create_state'}->{'id'} ),
+ node_uuid => $self->ticket_uuid($args{'create_state'}->{'id'}),
change_type => 'update_file'
}
);
@@ -283,7 +290,7 @@
my $change = Prophet::Change->new(
{ node_type => 'ticket',
- node_uuid => $self->sync_source->uuid_for_url( $self->url . "/ticket/" . $args{'create_state'}->{'id'} ),
+ node_uuid => $self->ticket_uuid($args{'create_state'}->{'id'}),
change_type => 'update_file'
}
);
More information about the Bps-public-commit
mailing list