madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[ljcom] r12755: LJSUP-13883: Journal pages optimizaiton ...

Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1
U   trunk/cgi-bin/LJ/Hooks/PartnerSites.pm
Modified: trunk/cgi-bin/LJ/Hooks/PartnerSites.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/PartnerSites.pm	2012-10-15 08:32:02 UTC (rev 12754)
+++ trunk/cgi-bin/LJ/Hooks/PartnerSites.pm	2012-10-15 09:00:22 UTC (rev 12755)
@@ -11,8 +11,10 @@
 
     my $journal = $entry->journal;
 
-    my $partner
-        = LJ::PartnerSite->find_by_journal_username( $journal->username );
+    my $partner = $journal->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $journal->username );
+    }
 
     return unless $partner && $partner->needs_sync_comments_count;
 
@@ -33,7 +35,11 @@
 
     return if ! $u || $u->equals( LJ::get_remote() );
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
+
     return unless $partner && $partner->overrides->{'userhead'};
 
     $$userhead_ref = $partner->overrides->{'userhead'};
@@ -44,7 +50,11 @@
 
     return if ! $u || $u->equals( LJ::get_remote() );
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
+
     return unless $partner && $partner->overrides->{'profile_url'};
 
     $$profile_url_ref = $partner->overrides->{'profile_url'};
@@ -53,9 +63,13 @@
 LJ::register_hook( 'override_display_name' => sub {
     my ( $u, $display_name_ref ) = @_;
 
-   return if ! $u || $u->equals( LJ::get_remote() );
+    return if ! $u || $u->equals( LJ::get_remote() );
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
+
     return unless $partner && $partner->overrides->{'display_name'};
 
     $$display_name_ref = $partner->overrides->{'display_name'};
@@ -79,12 +93,10 @@
 LJ::register_hook( 'override_entry_url' => sub {
     my ( $u, $entry, $entry_url_ref ) = @_;
 
-    my $jitemid   = $entry->jitemid;
-    my $key       =  "__partner_site_$jitemid";
+    my $key       =  '__override_entry_url';
+    return $entry->{$key} 
+        if exists $entry->{$key};
 
-    return $u->{$key} 
-        if exists $u->{$key};
-
     return if ! $u || $u->equals( LJ::get_remote() );
 
     my $partner = $u->{'__partner_journal'};
@@ -97,7 +109,7 @@
     return unless $docid;
 
     $$entry_url_ref = $partner->article_link($docid);
-    $u->{$key} = $$entry_url_ref;
+    $entry->{$key} = $$entry_url_ref;
 } );
 
 LJ::register_hook( 'override_comments_url' => sub {
@@ -105,7 +117,11 @@
 
     return if ! $u || $u->equals( LJ::get_remote() );
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
+
     return unless $partner && $partner->overrides->{'comments_url'};
 
     my $docid = $partner->docid_from_entry($entry);
@@ -136,15 +152,23 @@
 LJ::register_hook( 'override_s2_link' => sub {
     my ( $u, $entry, $key, $link_ref ) = @_;
 
+    my $ch_key = '__override_s2_link';
+    return $entry->{$ch_key}
+            if $entry->{$ch_key};
+
     return if ! $u || $u->equals( LJ::get_remote() );
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
     return unless $partner && $partner->overrides->{'s2_links'};
 
     my $docid = $partner->docid_from_entry($entry);
     return unless $docid;
 
     $$link_ref = { '_type' => 'Link', '_isnull' => 1 };
+    $entry->{$ch_key} = $$link_ref;
 } );
 
 LJ::register_hook( 'override_auth_sequence' => sub {
@@ -152,7 +176,11 @@
 
     return unless $u;
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
+
     return unless $partner && $partner->overrides->{'auth_sequence'};
 
     @$auth_sequence = split(' ', $partner->overrides->{'auth_sequence'});
@@ -164,7 +192,11 @@
     return unless $u;
     return unless $link;
 
-    my $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    my $partner = $u->{'__partner_journal'};
+    unless ($partner) {
+        $partner = LJ::PartnerSite->find_by_journal_username( $u->username );
+    }
+
     return unless $partner && $partner->overrides->{'extended_entry'};
 
     my $ua = LWP::UserAgent->new;    

Tags: ljcom, 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