/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 198 - (hide annotations)
Tue Jun 17 23:04:00 2008 UTC (15 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 971 byte(s)
import sites from all strix instances
1 dpavlin 198 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use lib 'lib';
7    
8     use Jifty;
9     use Data::Dump qw/dump/;
10    
11     my $debug = 0;
12    
13     BEGIN { Jifty->new; };
14     Jifty->web->request(Jifty::Request->new);
15     Jifty->web->response(Jifty::Response->new);
16    
17     #my $config = Jifty->config->app('strix') or die "need strix config";
18    
19     my $instances = A3C::Model::StrixInstanceCollection->new;
20     $instances->unlimit;
21    
22     my $ss = A3C::Model::StrixSite->new;
23    
24     my ( $total_sites, $total_instances ) = ( 0, 0 );
25    
26     while ( my $i = $instances->next ) {
27     my $dbh = eval { Strix->new({ instance => $i->instance })->dbh };
28     next if $@;
29     my $sth = $dbh->prepare(qq{ select * from site });
30     $sth->execute;
31    
32     $total_instances++;
33    
34     while ( my $row = $sth->fetchrow_hashref ) {
35     warn dump( $row ) if $debug;
36     $row->{instance} = $i->instance;
37     $row->{site_id} = delete( $row->{id} );
38     $ss->load_or_create( %$row );
39     $total_sites++ if $ss->id;
40     }
41     }
42    
43     Jifty->log->info( "$total_sites Strix sites from $total_instances imported" );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26