Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1U trunk/cgi-bin/LJ/RelationService.pm U trunk/cgi-bin/LJ/S2.pm U trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/RelationService.pm =================================================================== --- trunk/cgi-bin/LJ/RelationService.pm 2012-10-16 07:46:08 UTC (rev 23143) +++ trunk/cgi-bin/LJ/RelationService.pm 2012-10-16 07:55:11 UTC (rev 23144) @@ -23,8 +23,12 @@ return 0 unless LJ::is_enabled('send_test_load_to_rs2'); - my $ext_block = LJ::ExtBlock->load_by_id('lj11_params'); - my $values = $ext_block ? LJ::JSON->from_json($ext_block->blocktext) : {}; + my $values = $singletons{'__lj11_params_value'}; + unless ($values) { + my $ext_block = LJ::ExtBlock->load_by_id('lj11_params'); + $values = $ext_block ? LJ::JSON->from_json($ext_block->blocktext) : {}; + $singletons{'__lj11_params_value'} = $values; + } if ($type eq 'F') { return 0 unless $values->{rs_enable_type_f}; @@ -184,8 +188,8 @@ return undef unless $u && $friend && $type; - return $singletons{$u->userid}->{$friend->userid}->{$type} - if exists $singletons{$u->userid}->{$friend->userid}->{$type} && !%opts; + return $singletons{$u->{userid}}->{$friend->{userid}}->{$type} + if exists $singletons{$u->{userid}}->{$friend->{userid}}->{$type} && !%opts; if ($class->_load_alt_api('read', $type)) { my $alt = $class->alt_api($u); @@ -196,10 +200,36 @@ my $interface = $class->relation_api($u); my $relation = $interface->is_relation_to($u, $friend, $type, %opts); - $singletons{$u->userid}->{$friend->userid}->{$type} = $relation; + $singletons{$u->{userid}}->{$friend->{userid}}->{$type} = $relation; return $relation; } +sub is_relation_to_v2 { + my $class = shift; + my $u = shift; + my $friend = shift; + my $type = shift; + my %opts = @_; + + return undef unless $u && $friend && $type && + $u->isa('LJ::User') && $friend->isa('LJ::User'); + + return $singletons{$u->{userid}}->{$friend->{userid}}->{$type} + if exists $singletons{$u->{userid}}->{$friend->{userid}}->{$type} && !%opts; + + if ($class->_load_alt_api('read', $type)) { + my $alt = $class->alt_api($u); + if ($alt) { + $alt->is_relation_to($u, $friend, $type, %opts); + } + } + + my $interface = $class->relation_api($u); + my $relation = $interface->is_relation_to($u, $friend, $type, %opts); + $singletons{$u->{userid}}->{$friend->{userid}}->{$type} = $relation; + return $relation; +} + sub is_relation_type_to { my $class = shift; my $u = shift; Modified: trunk/cgi-bin/LJ/S2.pm =================================================================== --- trunk/cgi-bin/LJ/S2.pm 2012-10-16 07:46:08 UTC (rev 23143) +++ trunk/cgi-bin/LJ/S2.pm 2012-10-16 07:55:11 UTC (rev 23144) @@ -4193,9 +4193,9 @@ $this->{'__jnc_cache'} = $etypeid; } - my $newentry_etypeid = 'LJ::Event::JournalNewEntry'->etypeid; - my $__get_newentry_info = sub { + my $newentry_etypeid = 'LJ::Event::JournalNewEntry'->etypeid; + my $newentry_sub = $this->{__newentry_sub}->{$journalu->id}; if ($remote && !$newentry_sub) { ($newentry_sub) = $remote->has_subscription( journalid => $journalu->id, @@ -4242,6 +4242,7 @@ arg1 => $this->{itemid}, ); + my $newentry_etypeid = 'LJ::Event::JournalNewEntry'->etypeid; return LJ::S2::Link("$LJ::SITEROOT/manage/subscriptions/entry.bml?journal=$journal&itemid=$this->{'itemid'}", $ctx->[S2::PROPS]->{"text_watch_comments"}, LJ::S2::Image("$LJ::IMGPREFIX/btn_track.gif", 24, 24, 'Track This', @@ -4273,6 +4274,7 @@ subid => $subscr->id, action => 'delsub'); + my $newentry_etypeid = 'LJ::Event::JournalNewEntry'->etypeid; return LJ::S2::Link("$LJ::SITEROOT/manage/subscriptions/entry.bml?journal=$journal&itemid=$this->{'itemid'}", $ctx->[S2::PROPS]->{"text_unwatch_comments"}, LJ::S2::Image("$LJ::IMGPREFIX/btn_tracking.gif", 24, 24, 'Untrack this', Modified: trunk/cgi-bin/LJ/User.pm =================================================================== --- trunk/cgi-bin/LJ/User.pm 2012-10-16 07:46:08 UTC (rev 23143) +++ trunk/cgi-bin/LJ/User.pm 2012-10-16 07:55:11 UTC (rev 23144) @@ -5660,7 +5660,7 @@ return undef if $u->{journaltype} =~ /^[PYR]$/; # check for supermaintainer access - return 1 if LJ::check_rel($u, $remote, 'S'); + return 1 if LJ::RelationService->is_relation_to_v2($u, $remote, 'S'); # not passed checks, return false return undef; @@ -5687,7 +5687,7 @@ return undef if $u->{journaltype} =~ /^[PYR]$/; # check for moderate access - return 1 if LJ::check_rel($u, $remote, 'M'); + return 1 if LJ::RelationService->is_relation_to_v2($u, $remote, 'M'); # passed not checks, return false return undef; @@ -5716,8 +5716,7 @@ # check for supermaintainer return 1 if $remote->can_super_manage($u); - # check for admin access - return undef unless LJ::check_rel($u, $remote, 'A'); + return 0 unless LJ::RelationService->is_relation_to_v2($u, $remote, 'A'); # passed checks, return true return 1;