Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r16520: Another performance bug fixed: don't loa...

Committer: gariev
Another performance bug fixed: don't load all messages just to delete some of them
U   trunk/cgi-bin/LJ/NotificationInbox.pm
Modified: trunk/cgi-bin/LJ/NotificationInbox.pm
===================================================================
--- trunk/cgi-bin/LJ/NotificationInbox.pm	2010-04-09 15:12:31 UTC (rev 16519)
+++ trunk/cgi-bin/LJ/NotificationInbox.pm	2010-04-10 12:12:06 UTC (rev 16520)
@@ -366,10 +366,8 @@
     if ($max && $self->count >= $max) {
 
         # Get list of bookmarks and ignore them when checking inbox limits
-        my $bmarks = join ',', map { $self->is_bookmark($_->qid) ? $_->qid : () } $self->items;
-        my $bookmark_sql = '';
-        $bookmark_sql = "AND qid NOT IN ($bmarks) " if ($bmarks);
-
+        my $bmarks = join ',', $self->get_bookmarks_ids;
+        my $bookmark_sql = ($bmarks) ? "AND qid NOT IN ($bmarks) " : '';
         my $too_old_qid = $u->selectrow_array
             ("SELECT qid FROM notifyqueue ".
              "WHERE userid=? $bookmark_sql".
@@ -456,6 +454,14 @@
     return;
 }
 
+## returns array of qid of 'bookmarked' messages
+sub get_bookmarks_ids {
+    my $self = shift;
+    
+    $self->load_bookmarks unless $self->{bookmarks};
+    return keys %{ $self->{bookmarks} };
+}
+
 # add a bookmark
 sub add_bookmark {
     my ($self, $qid) = @_;

Tags: gariev, livejournal, pm
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