fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-06-15 04:26 pm

[dw-free] Latest Things by tag duplicates entries if more than one tag is used

[commit: http://hg.dwscoalition.org/dw-free/rev/94a956a9a20e]

http://bugs.dwscoalition.org/show_bug.cgi?id=2086

Only show an entry once per feed.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/LatestFeed.pm
--------------------------------------------------------------------------------
diff -r a288bf7c1f88 -r 94a956a9a20e cgi-bin/DW/LatestFeed.pm
--- a/cgi-bin/DW/LatestFeed.pm	Tue Jun 15 21:40:53 2010 +0800
+++ b/cgi-bin/DW/LatestFeed.pm	Wed Jun 16 00:31:48 2010 +0800
@@ -289,16 +289,22 @@ sub _process_queue {
         delete $item->{obj};
         delete $item->{obj_entry};
 
+        # make sure we only add once, if the entry has multiple tags that map to the same feed
+        my %feed_added;
+
         # step 7.5) if the entry contains any tags that we are currently showing
         # globally, then put that onto the list
         foreach my $tag ( $ent->tags ) {
 
             # some lists we guarantee are always shown, these are the special feeds that actually
             # allow combining tags and things...
-            if ( my $feed = $LJ::LATEST_TAG_FEEDS{tag_maps}->{$tag} ) {
+            my $feed;
+            if ( ( $feed = $LJ::LATEST_TAG_FEEDS{tag_maps}->{$tag} ) and ( ! $feed_added{$feed} ) ) {
                 my $nom = "latest_items_tag:$feed";
                 $lists{$nom} ||= LJ::MemCache::get( $nom ) || [];
                 unshift @{$lists{$nom}}, $item;
+
+                $feed_added{$feed}++;
             }
 
             # and now we try to determine if a tag is popular (top-N) and if so, then we also want
--------------------------------------------------------------------------------