# Discourse Post Voting

**URL:** https://meta.discourse.org/t/discourse-post-voting/227808
**Category:** Plugin
**Tags:** official, post-voting, included-in-core
**Created:** [May 23, 2022, 7:55am UTC](https://meta.discourse.org/t/discourse-post-voting/227808 "2022-05-23T07:55:00Z")
**Posts on this page:** 1
**Showing post:** 149

<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: [May 10, 2025, 1:29pm UTC](https://meta.discourse.org/t/discourse-post-voting/227808/149 "2025-05-10T13:29:32Z")

</div>

> [@Shauny](#):
>
> Why does the first post (the OP) get voting options? Surely that’s the question, so should not be voted on like it’s an answer?

I think this also. 🙂 But Sam is adamant that it is a thing:

> [@Voting button appears on opening post](https://meta.discourse.org/t/voting-button-appears-on-opening-post/244144/6):
>
> This is very much a site pref. Voting on quality of questions is something pretty established on Stack Overflow like sites.
> 
> We kept the voting control deliberately, removing it via CSS is fine though, open to maybe adding a site setting for it as well.

> [@Shauny](#):
>
> Any hints on some Badge SQL I can use to make badges out of these? Get 10 votes in a vote post topic, etc…?

It doesn’t look like there are any badges knocking around for this yet.

If you have specific badge criteria for any you’d like to create you should fire up a #data-reporting topic for each one. 👍

I think a couple of examples could be along the lines of:

**get 10 votes on a post voting reply**

```sql
SELECT p.user_id, p.created_at AS granted_at, p.id AS post_id
FROM post_voting_votes pvv
  JOIN posts p ON p.id = pvv.votable_id
WHERE pvv.direction = 'up'
  AND p.post_number <> 1
  AND (:backfill OR p.id IN (:post_ids))
GROUP BY p.user_id, p.id
HAVING COUNT(*) >=10

```

Or a slightly more nuanced one where you accounted for ‘up - down’ votes:

```sql
WITH vote_totals AS (

SELECT 
    p.user_id,
    p.id AS post_id,
    p.created_at AS granted_at,
    (COUNT(*) FILTER (WHERE pvv.direction = 'up') - COUNT(*) FILTER (WHERE pvv.direction = 'down')) AS total
FROM post_voting_votes pvv
  JOIN posts p ON p.id = pvv.votable_id
WHERE p.post_number <> 1
GROUP BY 1, 2

)

SELECT *
FROM vote_totals 
WHERE total >= 10
  AND (:backfill OR post_id IN (:post_ids))

```

❗ These will need some further testing to make sure they’re working as intended. 🙂

Though one thing to consider is that the total is dynamic so a ‘10’ today could turn into a ‘5’ tomorrow if more downvotes are added (for the second example). And if the badge is just based on upvotes like the first example then you may have got 10, but the UI only shows 5 when the downvotes are totalled in.

---

_[View the full topic](https://meta.discourse.org/t/discourse-post-voting/227808)._
