Show
Ignore:
Timestamp:
05/18/06 18:19:44 (6 years ago)
Author:
nick
Message:

Improve the node versions listing code and tests

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Database.pm

    r298 r299  
    14641464    $sth->execute( $node_id ); 
    14651465 
     1466        # Need to hold onto the last row by hash ref, so we don't trash 
     1467        #  it every time 
     1468        my %first_data; 
     1469        my $dataref = \%first_data; 
     1470 
    14661471        # Haul out the data 
    14671472        my @versions; 
    14681473        while(my @results = $sth->fetchrow_array) { 
    1469                 # TODO: Support metadata multi-rows 
    1470                 my %data; 
     1474                my %data = %$dataref; 
     1475 
     1476                # Is it the same version as last time? 
     1477                if(%data && $data{'version'} != $results[2]) { 
     1478                        # New version 
     1479                        push @versions, $dataref; 
     1480                        %data = (); 
     1481                } else { 
     1482                        # Same version as last time, must be more metadata 
     1483                } 
     1484 
     1485                # Grab the core data (will be the same on multi-row for metadata) 
    14711486                @data{ qw( node_id name version last_modified ) } = @results; 
    14721487 
     
    14771492                } 
    14781493                if($with_metadata) { 
    1479                         warn("Not supported properly yet"); 
     1494                        my ($m_type,$m_value) = @results[$i,($i+1)]; 
     1495                        $data{'metadata'}->{$m_type} = $m_value; 
    14801496                } 
    14811497 
    1482                 push @versions, \%data; 
     1498                # Save where we've got to 
     1499                $dataref = \%data; 
     1500        } 
     1501 
     1502        # Handle final row saving 
     1503        if($dataref) { 
     1504                push @versions, $dataref; 
    14831505        } 
    14841506