29 |
|
|
30 |
my $sql = qq{ |
my $sql = qq{ |
31 |
select |
select |
32 |
items.id as _id, |
i.id as item_id, |
33 |
items.*, |
-- i.guid as _id, |
34 |
feeds.url as feed_url, |
i.link as _id, |
35 |
feeds.title as feed_title, |
i.*, |
36 |
feeds.link as feed_link, |
f.url as feed_url, |
37 |
feeds.description as feed_description |
f.title as feed_title, |
38 |
from items |
f.link as feed_link, |
39 |
join published_items on items.id = item_id |
f.description as feed_description |
40 |
join feeds on items.feed_id = feeds.id |
from items i |
41 |
where items.id > ? |
join published_items p on i.id = p.item_id |
42 |
order by items.id asc |
join feeds f on i.feed_id = f.id |
43 |
|
where i.id > ? |
44 |
|
order by i.id asc |
45 |
limit 1000 |
limit 1000 |
46 |
}; |
}; |
47 |
|
|
98 |
my $row_tags = $sth_tags->fetchrow_hashref(); |
my $row_tags = $sth_tags->fetchrow_hashref(); |
99 |
|
|
100 |
while (my $row = $sth->fetchrow_hashref() ) { |
while (my $row = $sth->fetchrow_hashref() ) { |
101 |
my $_id = $row->{_id} || die "row needs _id"; |
my $_id = $row->{_id} || "c$count"; |
102 |
|
$_id =~ s{\W+}{_}g; |
103 |
|
$_id =~ s{_+$}{}; |
104 |
my $doc = $db->newDoc( $_id ); |
my $doc = $db->newDoc( $_id ); |
105 |
|
|
106 |
while ( $row_tags && $row_tags->{item_id} < $row->{_id} ) { |
while ( $row_tags && $row_tags->{item_id} < $row->{item_id} ) { |
107 |
$row_tags = $sth_tags->fetchrow_hashref(); |
$row_tags = $sth_tags->fetchrow_hashref(); |
108 |
warn "## got tags: ",dump( $row_tags ) if $debug; |
warn "## got tags: ",dump( $row_tags ) if $debug; |
109 |
} |
} |
114 |
$doc->addAttachment( 'item.xml', 'application/xhtml+xml', $a ) if $a; |
$doc->addAttachment( 'item.xml', 'application/xhtml+xml', $a ) if $a; |
115 |
$a = delete( $row->{content} ); |
$a = delete( $row->{content} ); |
116 |
$doc->addAttachment( 'content.html', 'text/html', $a ) if $a; |
$doc->addAttachment( 'content.html', 'text/html', $a ) if $a; |
117 |
if ( $row_tags && $row_tags->{item_id} == $row->{_id} ) { |
if ( $row_tags && $row_tags->{item_id} == $row->{item_id} ) { |
118 |
$row->{tags} = [ split(/\s+/, $row_tags->{tags} ) ]; |
$row->{tags} = [ split(/\s+/, $row_tags->{tags} ) ]; |
119 |
warn "++ ",$row->{item_id}, dump( $row->{tags} ); |
warn "++ ",$row->{item_id}, dump( $row->{tags} ); |
120 |
} |
} |