# Reply counts on topics with auto-deleting posts

**URL:** https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115
**Category:** Bug
**Created:** [June 27, 2020, 5:51pm UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115 "2020-06-27T17:51:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [June 27, 2020, 5:51pm UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115/1 "2020-06-27T17:51:07Z")

</div>

Just noticed that when it had unread replies, the unread reply count on the Postgres 12 announcement topic was at 303 (blue circle with 303). Upon opening the topic the latest reply the count changed to 1.

The topic is set to auto delete replies older than 5 days, there’s currently only one reply on that topic.

Looks like the reply count on auto pruning topics with unread posts isn’t calculated correctly?

This was on mobile, I didn’t think to check desktop before opening the topic and marking it read.

---

<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: [June 27, 2020, 6:38pm UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115/2 "2020-06-27T18:38:35Z")

</div>

Yes, this is a known issue that has existed in Discourse since practically V1. Lots of deletions then a reply will always cause this mismatch, until the next visit of the topic. Doesn’t matter if they are automatic or manual deletions.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [June 27, 2020, 6:39pm UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115/3 "2020-06-27T18:39:40Z")

</div>

I guess the combination of auto deletion and that particular topic just makes it that much more obvious.

How unpleasant is the fix?

---

<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: [June 27, 2020, 6:42pm UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115/4 "2020-06-27T18:42:08Z")

</div>

To me it’s a little bit of a feature, albeit an odd one… you know that a bunch of stuff was deleted when you visit.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 30, 2020, 7:47am UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115/5 "2020-06-30T07:47:26Z")

</div>

> [@Stephen](#):
>
> How unpleasant is the fix?

Just to close the circle here, a fix here is massively extremely unpleasant, backend never actually counts specifically how many posts you have unread, it relies on a delta of `highest_post_number` and the last `post_number` you visited in topic users.

If I had to put a number on this, if my only job was to fix this bug it would take me **multiple months** to fix and I would have to invent a custom data store to get it going. Running a `count(*)` query on every unread topic is off the table.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 10, 2023, 8:53am UTC](https://meta.discourse.org/t/reply-counts-on-topics-with-auto-deleting-posts/156115/6 "2023-06-10T08:53:45Z")

</div>


