Changeset 236
- Timestamp:
- 09/05/06 16:47:36 (2 years ago)
- Files:
-
- 1 modified
-
TagSupplementals/trunk/TagSupplementals.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
TagSupplementals/trunk/TagSupplementals.pl
r235 r236 86 86 my $r = MT::Request->instance; 87 87 my $otag_cache = $r->stash('object_tags_cache:' . $blog_id) || {}; 88 if (!$otag_cache ) {88 if (!$otag_cache->{$tag_id}) { 89 89 my @otags = MT::ObjectTag->load({ 90 90 blog_id => $blog_id, … … 92 92 object_datasource => MT::Entry->datasource, 93 93 }); 94 $otag_cache = \@otags;94 $otag_cache->{$tag_id} = \@otags; 95 95 $r->stash('object_tags_cache:' . $blog_id, $otag_cache); 96 96 } 97 $otag_cache ;97 $otag_cache->{$tag_id}; 98 98 } 99 99 … … 103 103 or return $ctx->_no_entry_error('MT' . $ctx->stash('tag')); 104 104 105 my $weight = $args->{weight} || ' idf';105 my $weight = $args->{weight} || 'constant'; 106 106 my $lastn = $args->{lastn} || 0; 107 107 … … 127 127 128 128 my %rank; 129 if ($weight eq 'idf') { 130 for my $tag_id (@tag_ids) { 131 my @otags = _object_tags($blog_id, $tag_id); 132 next if scalar @otags == 1; 133 my $rank = 1 / (scalar @otags - 1); 134 for my $otag (@otags) { 135 $rank{$otag->object_id} += $rank; 136 } 137 } 138 } elsif ($weight eq 'constant') { 129 if ($weight eq 'constant') { 139 130 if (MT::Object->driver->can('count_group_by')) { 140 131 my $iter = MT::ObjectTag->count_group_by({ … … 158 149 } 159 150 } 160 delete $rank{$entry_id}; 161 } 151 } elsif ($weight eq 'idf') { 152 for my $tag_id (@tag_ids) { 153 my $otags = _object_tags($blog_id, $tag_id); 154 next if scalar @$otags == 1; 155 my $rank = 1 / (scalar @$otags - 1); 156 for my $otag (@$otags) { 157 $rank{$otag->object_id} += $rank; 158 } 159 } 160 } 161 delete $rank{$entry_id}; 162 162 163 163 my @eids = sort { $b <=> $a } keys %rank; … … 200 200 my $blog_id = $ctx->stash('blog_id') or return ''; 201 201 202 my @otags = _object_tags($blog_id, $tag->id);203 my @eids = map { $_->object_id } @ otags;202 my $otags = _object_tags($blog_id, $tag->id); 203 my @eids = map { $_->object_id } @$otags; 204 204 205 205 my $iter = MT::Tag->load_iter(undef, {
![(please configure the [header_logo] section in trac.ini)](/public/chrome/common/trac_banner.png)