[Bps-public-commit] SD branch, master, updated. 0.70-37-g209e982

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Sep 3 23:15:21 EDT 2009


The branch, master has been updated
       via  209e982ebdb2ab6283074007d39f546ac9e28827 (commit)
      from  de37c2b45a9f9877b65906e93c0cf2defc404360 (commit)

Summary of changes:
 lib/App/SD/Replica/lighthouse.pm             |    5 +++--
 lib/App/SD/Replica/lighthouse/PullEncoder.pm |   25 +++++++++++++------------
 2 files changed, 16 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit 209e982ebdb2ab6283074007d39f546ac9e28827
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Sep 4 11:15:07 2009 +0800

    use sequence we made up as identifier for comments in lighthouse

diff --git a/lib/App/SD/Replica/lighthouse.pm b/lib/App/SD/Replica/lighthouse.pm
index c8ee855..8b3a5b1 100644
--- a/lib/App/SD/Replica/lighthouse.pm
+++ b/lib/App/SD/Replica/lighthouse.pm
@@ -82,14 +82,15 @@ sub get_txn_list_by_date {
     my $ticket_obj = $self->lighthouse->ticket;
     $ticket_obj->load($ticket);
         
+    my $sequence = 0;
     my @txns = map {
         {
-            id      => $_->number,
+            id      => $sequence++,
             creator => $_->creator_name,
             created => $_->created_at->epoch,
         }
       }
-      sort { $b->created_at <=> $a->created_at } @{ $ticket_obj->versions };
+      @{ $ticket_obj->versions };
     return @txns;
 }
 
diff --git a/lib/App/SD/Replica/lighthouse/PullEncoder.pm b/lib/App/SD/Replica/lighthouse/PullEncoder.pm
index b405e9a..52ebab2 100644
--- a/lib/App/SD/Replica/lighthouse/PullEncoder.pm
+++ b/lib/App/SD/Replica/lighthouse/PullEncoder.pm
@@ -66,7 +66,10 @@ Returns a reference to an array of all transactions (as hashes) on ticket $id af
 sub find_matching_transactions {
     my $self     = shift;
     my %args     = validate( @_, { ticket => 1, starting_transaction => 1 } );
-    my @raw_versions = @{ $args{ticket}->versions };
+    my $sequence = 0;
+    # hack, let's add sequence for comments
+    my @raw_versions =
+      map { $_->{sequence} = $sequence++; $_ } @{ $args{ticket}->versions };
     my @raw_attachments = @{ $args{ticket}->attachments|| [] };
 
     my @raw_txns = ( @raw_versions, @raw_attachments );
@@ -78,9 +81,11 @@ sub find_matching_transactions {
         next if $txn_date < ( $args{'starting_transaction'} || 0 );
 
         # Skip things we've pushed
-        next if (
+        next
+          if (
             $self->sync_source->foreign_transaction_originated_locally(
-                $txn_date, $args{'ticket'}->number
+                ( defined $txn->{sequence} ? $txn->{sequence} : $txn->id ),
+                $args{'ticket'}->number
             )
           );
 
@@ -88,10 +93,7 @@ sub find_matching_transactions {
           {
             timestamp => $txn->created_at,
             object    => $txn,
-            serial    => $txn->created_at->epoch,
-            $txn->created_at == $args{ticket}->created_at
-            ? ( is_create => 1 )
-            : (),
+            serial    => defined $txn->{sequence} ? $txn->{sequence} : $txn->id,
           };
     }
 
@@ -111,7 +113,7 @@ sub transcode_create_txn {
     my $changeset = Prophet::ChangeSet->new(
         {
             original_source_uuid => $ticket_uuid,
-            original_sequence_no => $created->epoch,
+            original_sequence_no => $ticket->{sequence},
             creator              => $creator,
             created              => $created->ymd . " " . $created->hms
         }
@@ -168,7 +170,7 @@ sub transcode_one_txn {
     my $ticket = shift;
 
     my $txn = $txn_wrapper->{object};
-    if ( $txn_wrapper->{is_create} ) {
+    if ( defined $txn->{sequence} && $txn->{sequence} == 0 ) {
         return $self->transcode_create_txn($txn_wrapper);
     }
 
@@ -181,7 +183,7 @@ sub transcode_one_txn {
         $changeset = Prophet::ChangeSet->new(
             {
                 original_source_uuid => $ticket_uuid,
-                original_sequence_no => $txn->created_at->epoch,
+                original_sequence_no => $txn->id,
                 creator =>
                   $self->resolve_user_id_to( undef, $txn->uploader_id ),
                 created => $txn->created_at->ymd . " " . $txn->created_at->hms
@@ -199,7 +201,7 @@ sub transcode_one_txn {
         $changeset = Prophet::ChangeSet->new(
             {
                 original_source_uuid => $ticket_uuid,
-                original_sequence_no => $txn->created_at->epoch,
+                original_sequence_no => $txn->{sequence},
                 creator =>
                   $self->resolve_user_id_to( undef, $txn->creator_name ),
                 created => $txn->created_at->ymd . " " . $txn->created_at->hms
@@ -390,7 +392,6 @@ sub resolve_user_id_to {
     shift;
     my $id   = shift;
     return $id;
-#    return $id . '@lighthouse';
 }
 
 __PACKAGE__->meta->make_immutable;

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



More information about the Bps-public-commit mailing list