Calculation of topic_count incorrect

I noticed a glitch where topics that are only in a parent category are not counted as part of the API’s topic_count.

The forum in question where I am a user is running Discourse v2.4.0.beta11, so I can imagine that this may have already been fixed in newer versions, but in case it hasn’t, here’s the report.

The forum has a structure similar to the following, with categories B and C being children of A:

    Forum
    ├── ...
    ├── Category A (n=0)
    │   ├── Category B (n=92)
    │   └── Category C (n=6)
    └── ...

I have written the value of the topic_count (from /c/xx/show.json) according to the API after each category. But in fact, there’s one topic (only) in category A, although the topic_count says zero. Accordingly, the topics_all_time (from categories.json) for category A says 98, while browsing through the topic_list (from /c/xx.json) also reveals 99.

I can also share details on the forum in question via PM, in case that helps.

It’d be more useful if you verified the bug still exists – 2.4 is quite out of date, and has multiple security vulnerabilities.

1 Like

So, I looked in a forum with a more recent version (2.7.0.beta8) and can verify it still exists. But the “odd topic” is the one that exists by default in every category, the “About the … category” one. So it might actually be on purpose, because additional topics that have been created manually in the parent category are counted.

1 Like