[Bast-commits] r9583 - ironman/branches/mk-ii/Perlanet-IronMan-0.02/lib/Perlanet

aCiD2 at dev.catalyst.perl.org aCiD2 at dev.catalyst.perl.org
Tue Jun 8 12:42:56 GMT 2010


Author: aCiD2
Date: 2010-06-08 13:42:56 +0100 (Tue, 08 Jun 2010)
New Revision: 9583

Modified:
   ironman/branches/mk-ii/Perlanet-IronMan-0.02/lib/Perlanet/IronMan.pm
Log:
De-duplication is now handled by Perlanet::DBIx::Class

Modified: ironman/branches/mk-ii/Perlanet-IronMan-0.02/lib/Perlanet/IronMan.pm
===================================================================
--- ironman/branches/mk-ii/Perlanet-IronMan-0.02/lib/Perlanet/IronMan.pm	2010-06-07 23:38:58 UTC (rev 9582)
+++ ironman/branches/mk-ii/Perlanet-IronMan-0.02/lib/Perlanet/IronMan.pm	2010-06-08 12:42:56 UTC (rev 9583)
@@ -114,31 +114,26 @@
 
 =cut
 
-override 'select_entries' => sub {
+=comment
+
+around 'select_entries' => sub {
+    my $orig = shift;
     my ($self, @feeds) = @_;
 
-    # Perlanet::Feed objects to return
-    my @feed_entries;
+    my @entries = $self->$orig(@feeds);
 
-    # Iterate over the feeds working on them.
-    for my $feed (@feeds) {
+    # Iterate over the XML::Feed::Entry objects
+    foreach my $entry (@entries) {
+        # Problem with XML::Feed's conversion of RSS to Atom
+        if ($xml_entry->issued && ! $xml_entry->modified) {
+            $xml_entry->modified($xml_entry->issued);
+        }
 
-        # Fetch the XML::Feed:Entry objects from the Perlanet::Feed object
-        my @entries = $feed->_xml_feed->entries;
+        # Always set category to something
+        unless(defined($xml_entry->category)) {
+            $xml_entry->category('');
+        }
 
-        # Iterate over the XML::Feed::Entry objects
-        foreach my $xml_entry (@entries) {
-
-            # Problem with XML::Feed's conversion of RSS to Atom
-            if ($xml_entry->issued && ! $xml_entry->modified) {
-              $xml_entry->modified($xml_entry->issued);
-            }
-
-            # Always set category to something
-            unless(defined($xml_entry->category)) {
-                $xml_entry->category('');
-            }
-
             #print(Dumper($xml_entry->tags));
             #print(Dumper($xml_entry->category));
 
@@ -151,12 +146,6 @@
                 next;
             }
 
-            # De-duplicate
-            unless($self->_filter_entry_for_duplicate($xml_entry)) {
-                #print("Skipping due to duplicate match for '" . $xml_entry->link . "'\n");
-                next;
-            }
-
             # Create a Perlanet::Entry object from the XML data retrieved
             my $entry = Perlanet::Entry->new(
                             _entry => $xml_entry,
@@ -170,6 +159,7 @@
     return @feed_entries;
 };
 
+=cut
 
 override 'insert_post' => sub {
     my ($self, $post) = @_;
@@ -242,32 +232,6 @@
     return $html_truncate;
 }
 
-=head2 _filter_entry_for_duplicate
-
-Test to see if the supplied XML::Feed::Entry passes the configured filters.
-
-Return 1 for a good entry and 0 for a bad entry.
-
-=cut
-
-sub _filter_entry_for_duplicate {
-    my $self = shift;
-    my $xml_entry = shift;
-
-    my $count = $self->schema->resultset('Post')->search(
-        { url => $xml_entry->link }
-    )->count;
-
-    if($count > 0) {
-        #print("Duplicate post found for url '" . $xml_entry->link . "'\n");
-        return 0;
-    }
-
-    #print("Post at url '" . $xml_entry->link . "' is new\n");
-
-    return 1;
-}
-
 =head2 _filter_entry_on_keywords
 
 Test to see if the supplied XML::Feed::Entry passes the configured filters.




More information about the Bast-commits mailing list