/[A3C]/bin/import-strix-sites.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/import-strix-sites.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 235 by dpavlin, Tue Jun 17 23:04:00 2008 UTC revision 236 by dpavlin, Sun Sep 7 21:22:10 2008 UTC
# Line 7  use lib 'lib'; Line 7  use lib 'lib';
7    
8  use Jifty;  use Jifty;
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10    use Strix::Import;
11    
12  my $debug = 0;  my $debug = 0;
13    
# Line 19  Jifty->web->response(Jifty::Response->ne Line 20  Jifty->web->response(Jifty::Response->ne
20  my $instances = A3C::Model::StrixInstanceCollection->new;  my $instances = A3C::Model::StrixInstanceCollection->new;
21  $instances->unlimit;  $instances->unlimit;
22    
 my $ss = A3C::Model::StrixSite->new;  
   
23  my ( $total_sites, $total_instances ) = ( 0, 0 );  my ( $total_sites, $total_instances ) = ( 0, 0 );
24    
25  while ( my $i = $instances->next ) {  while ( my $i = $instances->next ) {
         my $dbh = eval { Strix->new({ instance => $i->instance })->dbh };  
         next if $@;  
         my $sth = $dbh->prepare(qq{ select * from site });  
         $sth->execute;  
   
26          $total_instances++;          $total_instances++;
27            $total_sites += Strix::Import->sites( $i->instance );
         while ( my $row = $sth->fetchrow_hashref ) {  
                 warn dump( $row ) if $debug;  
                 $row->{instance} = $i->instance;  
                 $row->{site_id} = delete( $row->{id} );  
                 $ss->load_or_create( %$row );  
                 $total_sites++ if $ss->id;  
         }  
28  }  }
29    
30  Jifty->log->info( "$total_sites Strix sites from $total_instances imported" );  Jifty->log->info( "$total_sites Strix sites from $total_instances imported" );

Legend:
Removed from v.235  
changed lines
  Added in v.236

  ViewVC Help
Powered by ViewVC 1.1.26