wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r17748: LJSUP-7052. Remove "truncate table". Fix...

Committer: gprochaev
LJSUP-7052. Remove "truncate table". Fix errors in view communities in verticals

U   trunk/bin/upgrading/update-db-general.pl
U   trunk/cgi-bin/LJ/Vertical.pm
Modified: trunk/bin/upgrading/update-db-general.pl
===================================================================
--- trunk/bin/upgrading/update-db-general.pl	2010-11-23 03:44:51 UTC (rev 17747)
+++ trunk/bin/upgrading/update-db-general.pl	2010-11-23 04:11:22 UTC (rev 17748)
@@ -4323,7 +4323,6 @@
     unless (column_type("vertical_keywords", "kw_id")) {
         do_alter("vertical_keywords",
             "ALTER TABLE vertical_keywords DROP PRIMARY KEY, DROP INDEX vert_id, DROP INDEX keyword, DROP journalid, DROP jitemid, DROP vert_id, DROP is_seo, ADD kw_id INT NOT NULL");
-        do_sql("TRUNCATE vertical_keywords");
         do_alter("vertical_keywords",
             "ALTER TABLE vertical_keywords ADD PRIMARY KEY(kw_id), ADD UNIQUE(keyword), MODIFY kw_id INT NOT NULL AUTO_INCREMENT");
     }

Modified: trunk/cgi-bin/LJ/Vertical.pm
===================================================================
--- trunk/cgi-bin/LJ/Vertical.pm	2010-11-23 03:44:51 UTC (rev 17747)
+++ trunk/cgi-bin/LJ/Vertical.pm	2010-11-23 04:11:22 UTC (rev 17748)
@@ -356,18 +356,37 @@
         or die "unable to contact global db master to create vertical";
     my $comms_search = $dbh->selectall_arrayref ("SELECT DISTINCT journalid FROM vertical_keywords w, vertical_keymap m WHERE m.jitemid <> 0 AND m.vert_id = ? AND w.kw_id = m.kw_id AND keyword like ?", { Slice => {} }, $self->vert_id, '%'.$search.'%') || [];
 
+    ## Get subcategories
     my $cats = $self->get_categories( $args{'category'} );
 
     my $cusers = {};
+
+    ## Load all communities from selected category
+    my $category = $args{'category'};
+    if ($category) {
+        $category->load_communities ( %args ) unless ($args{'is_need_child'} && $category->{_loaded_journals});
+        my $comms = $category->{communities};
+    
+        $comms = @$comms_search
+                ? [ grep { my $s_comm_id = $_->{journalid}; grep { $s_comm_id == $_ } @$comms } @$comms_search ]
+                : [ map { { journalid => $_ } } @$comms ];
+
+        $cusers = LJ::load_userids(map { $_->{journalid} } @$comms);
+    }
+
     foreach my $c (@$cats) {
         my $cat = LJ::Browse->load_by_id ( $c->{catid} );
 
+        ## Load all communities from subcategory
         $cat->load_communities ( %args ) unless ($args{'is_need_child'} && $cat->{_loaded_journals});
+        my $comms = $cat->{communities};
 
-        my $comms = $cat->{communities};
+        ## apply a user search if need
         $comms = @$comms_search
                 ? [ grep { my $s_comm_id = $_->{journalid}; grep { $s_comm_id == $_ } @$comms } @$comms_search ]
                 : [ map { { journalid => $_ } } @$comms ];
+
+        ## join with common communities hash
         my $temp_users = LJ::load_userids(map { $_->{journalid} } @$comms);
         foreach my $userid (keys %$temp_users) {
             $cusers->{$userid} = $temp_users->{$userid};

Tags: livejournal, pl, pm, wisest-owl
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