dreamwidth/dw-free — pull request #70 by swaldman3 (2012-09-10 16:07:52+00:00)
Title: Bug 1723 - tag counts

Fix for Bug 1723 (which, rather wonderfully, was created in response to a support request that I made in 2009!).

Giving an accurate count of tag usage in posts that the current user can see would require trawling the database every time. This is what I think is the closest approximation we can reach without doing that:

- If the user is looking at their own journal, just pass them the total number of uses of the tag
- If the user is logged out or does not have access, just pass them the number of public uses of the tag
- If the user has access but is not a member of any access filters, pass public + protected uses
- If they are a member of one or more access filters, pass public + protected uses + the number of uses due to the group that they are a member of that has the largest number of uses of that tag. (convoluted sentence ahoy. Sorry)

This will often be accurate, and will sometimes be an underestimate. It should never be an overestimate.

This is run a lot - any time that a journal page with a tags module is displayed, as well as tags pages - so performance optimisations are gratefully solicited!

In an ideal world, somebody using viewall should be shown an accurate count too, but I thought that the overhead of checking for viewall every time probably wasn't worth it.