/[Grep]/lib/Grep/Action/Fetch.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Action/Fetch.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Tue Feb 20 21:55:24 2007 UTC revision 46 by dpavlin, Tue Feb 20 22:44:59 2007 UTC
# Line 107  sub take_action { Line 107  sub take_action {
107    
108          warn "getting entries from ", $xml_feed->title, "\n";          warn "getting entries from ", $xml_feed->title, "\n";
109    
110            my $new;
111    
112          for my $entry ($xml_feed->entries) {          for my $entry ($xml_feed->entries) {
113                  my $i = Grep::Model::Item->new();                  my $i = Grep::Model::Item->new();
114    
115                  $i->load_or_create(                  my ($ok,$msg) = $i->load_or_create(
116                          in_feed => $feed,                          in_feed => $feed,
117                          title => $entry->title,                          title => $entry->title,
118                          link => $entry->link,                          link => $entry->link,
# Line 122  sub take_action { Line 124  sub take_action {
124                          modified => $entry->modified ? $entry->modified->strftime("%Y-%m-%d %H:%M:%S") : undef,                          modified => $entry->modified ? $entry->modified->strftime("%Y-%m-%d %H:%M:%S") : undef,
125                  );                  );
126    
127                  if ( $i->id ) {                  if ( $ok ) {
128                            Jifty->log->debug("item ", $i->id, ": $msg");
129                          $items->add_record( $i );                          $items->add_record( $i );
130                            # count new objects
131                          Jifty->log->debug("added ", $i->id, " to collection");                          $new++ if ($msg !~ m/^Found/);
132                  } else {                  } else {
133                          warn "can't add entry ", dump( $entry ) unless ( $i->id );                          warn "can't add entry ", dump( $entry ), "\n";
134                  }                  }
135    
136          }          }
137    
138          if ( my $count = $items->count ) {          if ( my $count = $items->count ) {
139    
140                  my $message = "$count results for '$q' in " . $feed->title;                  # construct a proper sentence :-)
141                    my $message = $count
142                            . ( $new == $count ? ' new' : '' )
143                            . ( $new == 0 ? ' old' : '' )
144                            . ' results '  
145                            . ( $new && $new < $count ? "of which $new new " : '' )
146                            . "for '$q' in " . $feed->title;
147            
148                  $self->result->message( $message );                  $self->result->message( $message );
149    
150                  $self->result->content( items => $items );                  $self->result->content( items => $items );

Legend:
Removed from v.45  
changed lines
  Added in v.46

  ViewVC Help
Powered by ViewVC 1.1.26