25 |
join feeds on items.feed_id = feeds.id |
join feeds on items.feed_id = feeds.id |
26 |
where items.id > ? |
where items.id > ? |
27 |
order by items.id asc |
order by items.id asc |
28 |
limit 1000 |
limit 5000 |
29 |
}; |
}; |
30 |
|
|
31 |
|
|
44 |
|
|
45 |
my $last_row = $status->{data}->{last_row_id} || 0; |
my $last_row = $status->{data}->{last_row_id} || 0; |
46 |
|
|
47 |
|
sub commit_last_row { |
48 |
|
warn "commit_last_row $last_row\n"; |
49 |
|
$status->{data}->{last_row_id} = $last_row; |
50 |
|
$status->update; |
51 |
|
} |
52 |
|
|
53 |
my $dbh = DBI->connect($dbi,"","") || die $DBI::errstr; |
my $dbh = DBI->connect($dbi,"","") || die $DBI::errstr; |
54 |
|
|
55 |
print "Fetching items from $dbi id > $last_row\n"; |
print "Fetching items from $dbi id > $last_row\n"; |
86 |
$doc->retrieve; |
$doc->retrieve; |
87 |
row2doc( $row, $doc )->update; |
row2doc( $row, $doc )->update; |
88 |
# eval { $doc->update }; |
# eval { $doc->update }; |
89 |
warn ( $@ ? "ERROR $_id $@" : "updated $_id" ), $/; |
warn $@ ? "ERROR $_id $@\n" : "updated $_id\n"; |
90 |
} else { |
} else { |
91 |
warn "created ",dump( $row ),$/; |
warn "created $_id\n"; |
92 |
} |
} |
93 |
|
|
94 |
|
$last_row = $row->{id}; |
95 |
$count++; |
$count++; |
96 |
if ( $count++ % 100 == 0 ) { # checkpoint every 100 records |
|
97 |
$status->{data}->{last_row_id} = $row->{id}; |
commit_last_row if $count % 100 == 0 # checkpoint every 100 records |
|
$status->update; |
|
|
} |
|
98 |
} |
} |
99 |
|
|
100 |
# end checkpoint |
commit_last_row; |
|
$status->{data}->{last_row_id} = $last_row; |
|
|
$status->update; |
|
101 |
|
|
102 |
__END__ |
__END__ |
103 |
|
|