improving the freshmeat feed
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Jun 2006 02:45:43 +0000 (02:45 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Jun 2006 02:45:43 +0000 (02:45 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4726 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm

index c2f686d..130c273 100644 (file)
@@ -512,14 +512,9 @@ sub escape {
 sub recent_changes {
        my $self = shift;
        my $client = shift;
-       my $when = shift;
+       my $when = shift || '1-01-01';
        my $limit = shift;
 
-       if (!$when) {
-               my ($d,$m,$y) = (localtime)[4,5,6];
-               $when = sprintf('%4d-%02d-%02d', $y + 1900, $m + 1, $d);
-       }
-
        my $type = 'biblio';
        $type = 'authority' if ($self->api_name =~ /authority/o);
 
@@ -531,7 +526,7 @@ sub recent_changes {
        return $_storage
                ->request(
                        "open-ils.cstore.direct.$type.record_entry.id_list.atomic",
-                       { $axis => { ">" => $when } },
+                       { $axis => { ">" => $when }, id => { '>' => 0 } },
                        { order_by => "$axis desc", limit => $limit } )
                ->gather(1);
 }
index 4db2a48..993783a 100644 (file)
@@ -449,8 +449,7 @@ sub changes_feed {
 
        $path =~ s/^\///og;
        
-       my ($type,$rtype,$axis,$date,$limit) = split '/', $path;
-       $date ||= 'today';
+       my ($type,$rtype,$axis,$limit,$date) = split '/', $path;
        $limit ||= 10;
 
        my $list = $supercat->request("open-ils.supercat.$rtype.record.$axis.recent", $date, $limit)->gather(1);
@@ -465,7 +464,12 @@ sub changes_feed {
        my $feed = create_record_feed( $type, $list, $unapi);
        $feed->root($root);
 
-       $feed->title("$limit most recent $rtype changes from $date forward");
+       if ($date) {
+               $feed->title("Up to $limit recent $rtype ${axis}s from $date forward");
+       } else {
+               $feed->title("$limit most recent $rtype ${axis}s");
+       }
+
        $feed->creator($host);
        $feed->update_ts(gmtime_ISO8601());
 
@@ -820,13 +824,14 @@ sub create_record_feed {
 
                my $item_tag = "tag:$host,$year:biblio-record_entry/$rec/$lib";
 
-
                my $xml = $supercat->request(
                        "open-ils.supercat.record.$type.retrieve",
                        $rec
                )->gather(1);
+               next unless $xml;
 
                my $node = $feed->add_item($xml);
+               next unless $node;
 
                if ($lib && $type eq 'marcxml') {
                        $xml = $supercat->request( "open-ils.supercat.record.holdings_xml.retrieve", $rec, $lib )->gather(1);
index ff206d8..1aa1f88 100644 (file)
@@ -20,6 +20,7 @@ sub new {
 sub build {
        my $class = shift;
        my $xml = shift;
+       return undef unless $xml;
 
        $parser = new XML::LibXML if (!$parser);
 
@@ -135,6 +136,7 @@ sub add_item {
 
        my $item_xml = shift;
        my $entry = $class->new($item_xml);
+       return undef unless $entry;
 
        $entry->base($self->base);
        $entry->unapi($self->unapi);
@@ -441,6 +443,7 @@ sub new {
        my $class = shift;
        my $xml = shift;
        my $self = $class->SUPER::build($xml);
+       return undef unless $self;
        $self->{doc}->documentElement->setNamespace('http://www.loc.gov/MARC21/slim', 'marc');
        $self->{type} = 'application/xml';
        $self->{holdings_xpath} = '/marc:record';