Henry Lyne (henrylyne) wrote in changelog,
Henry Lyne
henrylyne
changelog

[livejournal] r15619: Allow data to be received from the maste...

Committer: henrylyne
Allow data to be received from the master DB, used especially if we just updated the master.
This should fix problems with pages not displaying the most recent listings after changes were just submitted.

U   trunk/cgi-bin/LJ/Browse.pm
U   trunk/htdocs/admin/browse/moderate_community.bml
U   trunk/htdocs/community/directory.bml
Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm	2009-08-20 10:48:38 UTC (rev 15618)
+++ trunk/cgi-bin/LJ/Browse.pm	2009-08-20 14:42:39 UTC (rev 15619)
@@ -1064,7 +1064,9 @@
 # Status can be: (P)ending, (A)pproved, (D)enied, (R)emoved
 sub get_communities {
     my $class = shift;
-    my ($c, @status) = @_;
+    my %opts = @_;
+    my $c = $opts{comm};
+    my @status = @{$opts{status}};
 
     # Default to Pending status
     my $status_sql = "'P'";
@@ -1074,7 +1076,8 @@
         $status_sql = "'" . $status_sql . "'";
     }
 
-    my $dbr = LJ::get_db_reader()
+    # allow read from master, used when listings were just changed
+    my $dbr = $opts{use_master} ? LJ::get_db_writer() : LJ::get_db_reader()
         or die "unable to contact global db reader to get category submissions";
     my $sth;
 
@@ -1107,16 +1110,20 @@
 
 sub get_submitted_communities {
     my $class = shift;
+    my %opts = @_;
     my @status = ('P','A','D');
+    $opts{status} = \@status;
 
-    return $class->get_communities(@_, @status);
+    return $class->get_communities(%opts);
 }
 
 sub get_pending_communities {
     my $class = shift;
+    my %opts = @_;
     my @status = ('P');
+    $opts{status} = \@status;
 
-    return $class->get_communities(@_, @status);
+    return $class->get_communities(%opts);
 }
 
 # is a community already in a category in the moderation table
@@ -1130,7 +1137,7 @@
         or die "unable to contact global db master to create category";
 
     my $sth = $dbh->prepare("SELECT pendid FROM categoryjournals_pending " .
-                    "WHERE status IN ('P','A') AND jid=? AND catid=?");
+                    "WHERE status IN ('P','A','D') AND jid=? AND catid=?");
     $sth->execute($jid, $catid);
     die $dbh->errstr if $dbh->err;
 

Modified: trunk/htdocs/admin/browse/moderate_community.bml
===================================================================
--- trunk/htdocs/admin/browse/moderate_community.bml	2009-08-20 10:48:38 UTC (rev 15618)
+++ trunk/htdocs/admin/browse/moderate_community.bml	2009-08-20 14:42:39 UTC (rev 15619)
@@ -17,6 +17,7 @@
     $title = "Moderate Community Directory Submissions";
     my $ret = "";
 
+    my $use_master = 0;
     if (LJ::did_post() and $POST{'update'}) {
         push @errors, "Invalid form submission" unless LJ::check_form_auth();
         {
@@ -43,14 +44,14 @@
             # Add journals to category
             unless (@errors) {
                 $ret .= "<span class='super notice'>Communities successfully updated.</span>";
-                return $ret;
+                $use_master = 1;
             } else {
                 $ret .= "<span class='super notice'>Communities not updated.</span>";
             }
         }
     }
 
-    my @listings = LJ::Browse->get_pending_communities(undef);
+    my @listings = LJ::Browse->get_pending_communities( use_master => $use_master );
     return $ret . "<p>No communities to moderate.</p>" unless @listings;
     @listings = sort { $a->{catid} <=> $b->{catid} } @listings;
     my @jids = map { $_->{jid} } @listings;

Modified: trunk/htdocs/community/directory.bml
===================================================================
--- trunk/htdocs/community/directory.bml	2009-08-20 10:48:38 UTC (rev 15618)
+++ trunk/htdocs/community/directory.bml	2009-08-20 14:42:39 UTC (rev 15619)
@@ -54,7 +54,7 @@
     my @caturl_;
     my @catrem;
     # Get categories the community belongs to or is pending approval for
-    my @listings = LJ::Browse->get_submitted_communities($c);
+    my @listings = LJ::Browse->get_submitted_communities( comm => $c );
     $limit = @listings if (@listings > $limit);
 
     foreach my $i (1..$limit) {
@@ -87,7 +87,7 @@
         }
 
         # reset upper limit
-        @listings = LJ::Browse->get_submitted_communities($c);
+        @listings = LJ::Browse->get_submitted_communities( comm => $c, use_master => 1);
         $limit = (@listings > 2) ? @listings : 2;
 
         $ret .= $response;

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