# Calculation of topic\_count incorrect

**URL:** https://meta.discourse.org/t/calculation-of-topic-count-incorrect/191395
**Category:** Bug
**Created:** [May 23, 2021, 7:50pm UTC](https://meta.discourse.org/t/calculation-of-topic-count-incorrect/191395 "2021-05-23T19:50:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fkohrt](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fkohrt](https://meta.discourse.org/u/fkohrt)
#### Post date: [May 23, 2021, 7:50pm UTC](https://meta.discourse.org/t/calculation-of-topic-count-incorrect/191395/1 "2021-05-23T19:50:24Z")

</div>

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:

```plaintext
    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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 23, 2021, 11:30pm UTC](https://meta.discourse.org/t/calculation-of-topic-count-incorrect/191395/2 "2021-05-23T23:30:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fkohrt](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fkohrt](https://meta.discourse.org/u/fkohrt)
#### Post date: [May 24, 2021, 8:13am UTC](https://meta.discourse.org/t/calculation-of-topic-count-incorrect/191395/3 "2021-05-24T08:13:10Z")

</div>

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.
