Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Performance fix: make TagCountUser not horribly slow

Returning thousands of rows only to count them with scalar()
is, it turns out, not the most efficient way of counting.
  • Loading branch information...
commit 6be49d8b0ca3b75957fd7dedd6621b02499baa59 1 parent ccc1d92
Jamie McCarthy authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 tagboxes/TagCountUser/TagCountUser.pm
7 tagboxes/TagCountUser/TagCountUser.pm
View
@@ -111,10 +111,9 @@ sub feed_userchanges {
sub run {
my($self, $affected_id) = @_;
- my $tagboxdb = getObject('Slash::Tagbox');
- my $user_tags_ar = $tagboxdb->getTagboxTags($self->{tbid}, $affected_id, 0);
- main::tagboxLog("TagCountUser->run called for $affected_id, ar count " . scalar(@$user_tags_ar));
- my $count = grep { !defined $_->{inactivated} } @$user_tags_ar;
+ my $tagboxdb = getObject('Slash::Tagbox', { db_type => 'reader' });
+ my $count = $tagboxdb->sqlCount('tags', "uid=$affected_id AND inactivated IS NULL");
+ main::tagboxLog("TagCountUser->run called for $affected_id, count $count");
$self->setUser($affected_id, { tag_count => $count });
}
Please sign in to comment.
Something went wrong with that request. Please try again.