# Incorrect Count on /tags page (included deleted topics - now fixed)

**URL:** <https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051>\
**Category:** Bug\
**Created:** [2016年十一月17日 23:27 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051 "2016-11-17T23:27:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)\
**Post date:** [2016年十一月17日 23:27 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/1 "2016-11-17T23:27:05Z")

</div>

**Summary:** Over at Stonehearth it was noticed by an Admin today that the count on the `/tags` page is incorrect for some tags.

**Steps to reproduce:**

Unknown.

**Expected Results:**

Number next to tags matches number of topics seen when viewing individual tag page.

**Actual Results:**

Number next to tags is greater than the number of topics seen when viewing individual tag page.

**Notes:**

The difference between the number of topics with a tag and the number displayed appears to be constant i.e. `ui` had the number 5 but had 3 topics, adding the `ui` tag to another topics caused the number to increase to 6.

This is known to be an issue with the following tags (this list may be incomplete): `ui`, `ai`, `crashes`,

**Attachments:**

 ![](https://global.discourse-cdn.com/meta/original/3X/6/9/69bfe660b43638be75390a8ebf5490bbb1091dfe.png)  
 ![](https://global.discourse-cdn.com/meta/original/3X/9/2/92340595e40770ac8a51e4d51a7fd00a16d1bfdb.png)

**Version Number:**

Discourse 1.7.0.beta7 ([discourse.stonehearth.net](http://discourse.stonehearth.net/))

**System Information:**

Windows 10 Education, Chrome Stable 54

---

<div class="post-metadata">

**Author:** ![ewanly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ewanly/32/62854_2.png) [@ewanly](https://meta.discourse.org/u/ewanly)\
**Post date:** [2016年十一月18日 11:34 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/2 "2016-11-18T11:34:32Z")

</div>

Is it possible, it’s happening because of Topics deletion not reflected to Tags counting?

---

<div class="post-metadata">

**Author:** ![GSeven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gseven/32/61731_2.png) [@GSeven](https://meta.discourse.org/u/GSeven)\
**Post date:** [2016年十一月18日 12:10 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/3 "2016-11-18T12:10:26Z")

</div>

Also, Tags are still counted on any hidden topics/posts

---

<div class="post-metadata">

**Author:** ![GSeven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gseven/32/61731_2.png) [@GSeven](https://meta.discourse.org/u/GSeven)\
**Post date:** [2016年十一月18日 12:27 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/4 "2016-11-18T12:27:02Z")

</div>

just a thought, what are numbers when you are logged out, is it a permissions thing?

---

<div class="post-metadata">

**Author:** ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)\
**Post date:** [2016年十一月18日 13:44 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/5 "2016-11-18T13:44:15Z")

</div>

> [@GSeven](#):
>
> Also, Tags are still counted on any hidden topics/posts

I checked adding `?status=deleted` to the end to the URL, no deleted topics appeared. I’m a moderator so I would see unlisted topics, and the person who reported this to me is an Admin, so she would see if there were any topics in an admin category that I couldn’t see.

> [@GSeven](#):
>
> just a thought, what are numbers when you are logged out, is it a permissions thing?

Same issue when logged out. Still seeing the number 6 but 4 topics for `ui`.

---

<div class="post-metadata">

**Author:** ![GSeven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gseven/32/61731_2.png) [@GSeven](https://meta.discourse.org/u/GSeven)\
**Post date:** [2016年十一月18日 15:43 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/6 "2016-11-18T15:43:49Z")

</div>

I don’t fully understand ‘make a topic into a private message’ yet, but i just made a topic, tagged it and turned it into a private message, and the tag count went up by one on the tag page.

could it be that?

deleting that private message keeps the tag count at +1

---

<div class="post-metadata">

**Author:** ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)\
**Post date:** [2016年十一月18日 16:20 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/7 "2016-11-18T16:20:00Z")

</div>

> [@GSeven](#):
>
> could it be that?

Certainly possible, but I highly, highly doubt it. We don’t use that function very much, and never for bug reports (the category where these tags are used).

---

<div class="post-metadata">

**Author:** ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)\
**Post date:** [2017年五月4日 19:56 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/8 "2017-05-04T19:56:54Z")

</div>

I ran into this today and I think it’s caused by deleted topics.

Steps to reproduce:

1. Create a new topic and add to it a new or existing tag;
2. Navigate to the `/tags` page and memorize the count next to the tag you added to the new topic;
3. Delete the new topic;
4. Go back to the `/tags` page and you’ll see the tag count isn’t updated.

I can reproduce this constantly on my local install.

---

<div class="post-metadata">

**Author:** ![clay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clay/32/102156_2.png) [@clay](https://meta.discourse.org/u/clay)\
**Post date:** [2017年八月18日 01:14 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/9 "2017-08-18T01:14:45Z")

</div>

I’m also seeing this problem with deleted topics, exactly as @Osama describes. We’re using tags heavily in the project in question and have need to sometimes automatically create a large number of tagged topics (importing data from elsewhere). The auto-imports occasionally catch unrelated content and we delete the topics, but the orphaned tags and incorrect tag counts persist.

---

<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:** [2017年八月18日 11:57 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/10 "2017-08-18T11:57:21Z")

</div>

@clay do you have a step by step sequence on how we would reproduce this?

---

<div class="post-metadata">

**Author:** ![clay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clay/32/102156_2.png) [@clay](https://meta.discourse.org/u/clay)\
**Post date:** [2017年八月18日 12:11 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/11 "2017-08-18T12:11:57Z")

</div>

1. Create a topic with tags

2. Later, delete that topic.

The tags & count remain on the /tags page.

I’m happy to give you access to the instance in question. Just PM me if so.

edit: not sure if it matters, but in step 2, “Later” means like a week later. I mention this in case there’s a sidkiq job that runs on a delayed schedule that affects tag processing. For the instance in question, I deleted the topics mentioned months ago and the orphaned tags and incorrect counts remain.

---

<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:** [2017年八月18日 12:13 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/12 "2017-08-18T12:13:09Z")

</div>

@neil perhaps you can have a look at this?

---

<div class="post-metadata">

**Author:** ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)\
**Post date:** [2017年八月22日 21:04 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/14 "2017-08-22T21:04:21Z")

</div>

I committed a fix for this issue. The counts won’t include deleted topics from now on.

---

<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:** [2017年八月28日 22:00 UTC](https://meta.discourse.org/t/incorrect-count-on-tags-page-included-deleted-topics-now-fixed/53051/15 "2017-08-28T22:00:24Z")

</div>

This topic was automatically closed after 6 days. New replies are no longer allowed.
