# Badge queries using "badge\_posts" table aren't awarded for non-public categories

**URL:** <https://meta.discourse.org/t/badge-queries-using-badge-posts-table-arent-awarded-for-non-public-categories/142639>\
**Category:** Product Support\
**Tags:** badges\
**Created:** [February 26, 2020, 4:00am UTC](https://meta.discourse.org/t/badge-queries-using-badge-posts-table-arent-awarded-for-non-public-categories/142639 "2020-02-26T04:00:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)\
**Post date:** [February 26, 2020, 4:00am UTC](https://meta.discourse.org/t/badge-queries-using-badge-posts-table-arent-awarded-for-non-public-categories/142639/1 "2020-02-26T04:00:01Z")

</div>

One of our users had 5 “Nice Reply” badges (liked 100 posts and gave 100 likes). Then we moved some topics to a private category, and now he has only 3 badges. It seems the badge query is not counting the likes given or received on the moved topics, perhaps because they moved or perhaps because they are now private.

In debugging this, I copied the badge query to [Data Explorer](https://meta.discourse.org/t/32566?silent=true):

```
select p.user_id, p.id post_id, current_timestamp granted_at
from badge_posts p
where p.post_number > 1
and p.like_count >= 10

```

The above query returns only 3 hits for the user, but it should be 5. I noticed it uses the table “badge\_posts”. I can’t find the badge\_posts table in the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) tree view. So I changed “badge\_posts” to “posts”, and then it returns 5 as expected.

Where does the “badge\_posts” table come from, and shouldn’t the badge query use the “posts” table instead?

---

_[View the full topic](https://meta.discourse.org/t/badge-queries-using-badge-posts-table-arent-awarded-for-non-public-categories/142639)._
