-#!/usr/bin/perl -w
-
+#!/usr/bin/perl
+use warnings;
use strict;
use DBI;
use Data::Dump qw/dump/;
my $sql = qq{
select
i.id as item_id,
--- i.guid as _id,
- i.link as _id,
- i.*,
+ md5(i.guid) as _id,
+
+ i.guid,
+ i.link,
+ i.title,
+ i.content,
+ i.author,
+ i.category,
+ i.modified,
+ i.timestamp,
+ i.insert_timestamp,
+
f.url as feed_url,
f.title as feed_title,
f.link as feed_link,
my $last_row = 0; # FIXME
$last_row = 0 if $debug;
-print "Fetching items from $dbi id > $last_row [$offset $limit]\n";
+warn "Fetching items from $dbi id > $last_row [$offset $limit]\n";
my $sth = $dbh->prepare($sql);
$sth->execute( $last_row );
$row->{feed} = $feed;
while ( $row_tags && $row_tags->{item_id} < $row->{item_id} ) {
- $row_tags = $sth_tags->fetchrow_hashref();
- warn "## got tags: ",dump( $row_tags ) if $debug;
- $row->{tags} = [ split(/\s+/, $row_tags->{tags} ) ];
+ if ( $row_tags = $sth_tags->fetchrow_hashref() ) {
+ warn "## got tags: ",dump( $row_tags ) if $debug;
+ $row->{tags} = [ split(/\s+/, $row_tags->{tags} ) ];
+ } else {
+ warn "end of tags";
+ $row_tags = undef;
+ }
}
# warn dump($row);
- print encode_json $row;
+ print encode_json($row),$/;
}