Hacking lightstats for ultimate tagness

I’ve hacked the lightstats plugin to forget about categories, and instead display “posts per tag” and “bytes per tag”, querying the tables created/maintained by ultimate tag warrior. Examples here. Code available by request.

Arguably the “posts per tag” is a bit redundant given the w00ty uber tag cloud – particularly once I have that displaying post counts in the tooltips. I’m quite proud of the “bytes per tag”, though… One big SQL statement gives me all I need:

SELECT tag, sum(length(post_content)) AS bytes
  FROM wp_post2tag
  INNER JOIN wp_tags ON wp_post2tag.tag_ID=wp_tags.tag_ID
  INNER JOIN wp_posts ON wp_post2tag.post_ID=wp_posts.ID
GROUP BY (wp_tags.tag_ID)

Well, OK, not so big. Quite big as a one-liner though. :-)

I’ve also installed wp-cache, which may or may not be pointless… (And, the following morning, disabled it, because it would prevent comments appearing for up to an hour after they’re posted!)