madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20561: LJSUP-10436: Remove delayed enties from ...

Committer: sbelyaev
LJSUP-10436: Remove delayed enties from 'recent entries' (S2)
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-11-17 12:29:05 UTC (rev 20560)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-11-17 13:12:05 UTC (rev 20561)
@@ -71,38 +71,6 @@
         $viewsome = $viewall || LJ::check_priv($remote, 'canview', 'suspended');
     }
 
-    my $delayed_entries;
-    
-    # calculate recent entries count
-    my $has_sticky = $u->has_sticky_entry;
-    my $delayed_entries_count = 0;
-    my $usual_skip = $skip;     
-
-    if (LJ::is_enabled("delayed_entries")) {
-        $delayed_entries_count = LJ::DelayedEntry->get_entries_count($u);
-        $usual_skip -= $delayed_entries_count;
-
-        if ($usual_skip < 0 ) {
-            $usual_skip = $skip ? $has_sticky : 0;
-        }
-
-        if (!$skip) {
-            $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow - $has_sticky);
-        } elsif ( $skip) {
-            $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip - $has_sticky, $itemshow);
-        }
-    }
-
-
-    if (!$delayed_entries) {
-        $delayed_entries = [];
-    }
-
-    my $itemshow_usual = $itemshow - scalar(@$delayed_entries);
-    if ( $itemshow_usual < 0 ) {
-        $itemshow_usual = 0;
-    }
-
     ## load the itemids
     my @itemids;
     my $err;
@@ -113,8 +81,8 @@
         'viewsome' => $viewsome,
         'userid' => $u->{'userid'},
         'remote' => $remote,
-        'itemshow' => $itemshow_usual + 1,
-        'skip' => $usual_skip,
+        'itemshow' => $itemshow + 1,
+        'skip' => $skip,
         'tagids' => $opts->{tagids},
         'tagmode' => $opts->{tagmode},
         'security' => $opts->{'securityfilter'},
@@ -125,14 +93,11 @@
         'err' => \$err,
         'poster'  => $get->{'poster'} || '',
         'show_sticky_on_top' => 1,
-    }) if ($itemshow_usual >= 0) ;
+    }) if ($itemshow >= 0) ;
     
-    my $is_prev_exist = scalar @items + scalar(@$delayed_entries) - $itemshow > 0 ? 1 : 0;
+    my $is_prev_exist = scalar @items - $itemshow > 0 ? 1 : 0;
     if ($is_prev_exist) {
-        if ( scalar(@$delayed_entries) > $itemshow ) {
-            pop @$delayed_entries;
-        }
-        if ( scalar(@items) + scalar(@$delayed_entries) > $itemshow ) {        
+        if ( scalar(@items) > $itemshow ) {        
             pop @items;
         } 
     }
@@ -168,12 +133,6 @@
     my $userlite_journal = UserLite($u);
     my $sticky_appended = !$u->has_sticky_entry() || $skip;
 
-    if ( scalar(@$delayed_entries) > 0 && 
-        ( ( $skip && $u->has_sticky_entry() ) || 
-         !$u->has_sticky_entry()) ) {
-        __append_delayed( $u, $delayed_entries,  $p->{'entries'} );
-    }
-  
   ENTRY:
     foreach my $item (@items)
     {
@@ -183,12 +142,6 @@
         my $ditemid = $itemid * 256 + $item->{'anum'};
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
         
-        # append delayed entries
-        if ( $entry_obj->is_sticky() && $sticky_appended ) {
-            __append_delayed( $u, $delayed_entries,  $p->{'entries'});
-            $sticky_appended = 1;
-        }
-        
         next ENTRY unless $entry_obj->visible_to($remote, {'viewall' => $viewall, 'viewsome' => $viewsome});
 
         $entry_obj->handle_prefetched_props($logprops{$itemid});
@@ -304,12 +257,6 @@
         push @{$p->{'entries'}}, $entry;
         LJ::run_hook('notify_event_displayed', $entry_obj);
 
-        # append delayed entries
-        if ( !$sticky_appended) {
-            __append_delayed( $u, $delayed_entries,  $p->{'entries'});
-            $sticky_appended = 1;
-        }
-        
     } # end huge while loop
 
     # mark last entry as closing.
@@ -341,7 +288,7 @@
     # unless we didn't even load as many as we were expecting on this
     # page, then there are more (unless there are exactly the number shown
     # on the page, but who cares about that)
-    unless (scalar(@items) + scalar(@$delayed_entries) != $itemshow) {
+    unless (scalar(@items) != $itemshow) {
         $nav->{'backward_count'} = $itemshow;
         if ($skip == $maxskip) {
             my $date_slashes = $lastdate;  # "yyyy mm dd";
@@ -364,67 +311,6 @@
     return $p;
 }
 
-sub __append_delayed {
-    my ( $u, $delayed, $entries) = @_;
-    
-    foreach my $delayedid  (@$delayed) {
-        my $delayed_entry = LJ::DelayedEntry->get_entry_by_id(  $u, 
-                                                                $delayedid, 
-                                                                { dateformat => 'S2' } );
-        my $permalink = $delayed_entry->url;
-        my $readurl = $permalink;
-        my $posturl = $permalink;
-        
-        my $comments = CommentInfo({
-            'read_url' => $readurl,
-            'post_url' => $posturl,
-            'count' => 0,
-            'maxcomments' => 0,
-            'maxcomments' => 0,
-            'enabled' => $delayed_entry->comments_shown,
-            'locked' => !$delayed_entry->posting_comments_allowed,
-            'maxcomments' => 0,
-            'enabled' => $delayed_entry->comments_shown,
-            'locked' => !$delayed_entry->posting_comments_allowed,
-            'screened' => 0,
-            'show_readlink' => 0,
-            'show_postlink' => 0,
-        });
-        
-        my $entry_tags =  $delayed_entry->get_tags;
-        $entry_tags = $entry_tags->{$delayed_entry->delayedid} if $entry_tags;
-        
-        my @tags = (); 
-        if ($entry_tags) {
-            my @keys = keys %$entry_tags;
-            foreach my $key (@keys) {
-                push @tags, Tag($delayed_entry->journal, $key => $entry_tags->{$key});
-            }
-        }
-        
-        my $entry = Entry($delayed_entry->journal, {
-            'subject' => $delayed_entry->subject,
-            'text' =>  $delayed_entry->event,
-            'dateparts' => $delayed_entry->alldatepart,
-            'system_dateparts' => $delayed_entry->system_alldatepart,
-            'security' => $delayed_entry->security || 0,
-            'allowmask' => $delayed_entry->allowmask || 0,
-            'journal' => UserLite($delayed_entry->journal),
-            'poster' => UserLite($delayed_entry->poster),
-            'comments' => $comments,
-            'new_day' => 1,
-            'end_day' => 0,   # if true, set later
-            'tags' => \@tags,
-            'userpic' => $delayed_entry->userpic,
-            'permalink_url' => "d$delayedid.html",
-            'sticky' => $delayed_entry->is_sticky,
-            'delayedid' => $delayed_entry->delayedid,
-        });
-        
-        push @$entries, $entry;
-    }
-}
 
-
 1;
 

Tags: livejournal, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments