# Testing poll votes

**URL:** <https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870>\
**Category:** Testing\
**Tags:** new\
**Created:** [October 26, 2023, 5:22pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870 "2023-10-26T17:22:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dax](https://sjc6.discourse-cdn.com/daxenterprisetest/user_avatar/daxenterprisetest.danibgz.com/dax/32/68_2.png) [@dax](https://daxenterprisetest.danibgz.com/u/dax)\
**Post date:** [October 26, 2023, 5:22pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/1 "2023-10-26T17:22:44Z")

</div>

Vote or die!!!

_Poll ([view on site](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/1))_

---

<div class="post-metadata">

**Author:** ![dax](https://sjc6.discourse-cdn.com/daxenterprisetest/user_avatar/daxenterprisetest.danibgz.com/dax/32/68_2.png) [@dax](https://daxenterprisetest.danibgz.com/u/dax)\
**Post date:** [October 26, 2023, 6:50pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/2 "2023-10-26T18:50:24Z")

</div>

Closed on October 26, 2023, 6:50pm UTC



---

<div class="post-metadata">

**Author:** ![dax](https://sjc6.discourse-cdn.com/daxenterprisetest/user_avatar/daxenterprisetest.danibgz.com/dax/32/68_2.png) [@dax](https://daxenterprisetest.danibgz.com/u/dax)\
**Post date:** [October 27, 2023, 1:06pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/3 "2023-10-27T13:06:32Z")

</div>

Opened on October 27, 2023, 1:06pm UTC



---

<div class="post-metadata">

**Author:** ![dax](https://sjc6.discourse-cdn.com/daxenterprisetest/user_avatar/daxenterprisetest.danibgz.com/dax/32/68_2.png) [@dax](https://daxenterprisetest.danibgz.com/u/dax)\
**Post date:** [October 27, 2023, 1:17pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/4 "2023-10-27T13:17:59Z")

</div>

_Poll ([view on site](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/4))_

---

<div class="post-metadata">

**Author:** ![dax](https://sjc6.discourse-cdn.com/daxenterprisetest/user_avatar/daxenterprisetest.danibgz.com/dax/32/68_2.png) [@dax](https://daxenterprisetest.danibgz.com/u/dax)\
**Post date:** [November 10, 2023, 5:27pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/5 "2023-11-10T17:27:37Z")

</div>

Unlisted on November 10, 2023, 5:27pm UTC



---

<div class="post-metadata">

**Author:** ![dax](https://sjc6.discourse-cdn.com/daxenterprisetest/user_avatar/daxenterprisetest.danibgz.com/dax/32/68_2.png) [@dax](https://daxenterprisetest.danibgz.com/u/dax)\
**Post date:** [November 10, 2023, 5:28pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/6 "2023-11-10T17:28:11Z")

</div>

Listed on November 10, 2023, 5:28pm UTC



---

<div class="post-metadata">

**Author:** ![anonymous1](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@anonymous1](https://daxenterprisetest.danibgz.com/u/anonymous1)\
**Post date:** [June 9, 2025, 12:12pm UTC](https://daxenterprisetest.danibgz.com/t/testing-poll-votes/870/8 "2025-06-09T12:12:16Z")

</div>

–[params]  
– string :query\_interval = 1 week  
– date :start\_date  
– date :end\_date

WITH query\_periods AS (  
SELECT  
generate\_series(:start\_date, :end\_date, :query\_interval::interval)::date AS period\_start,  
(generate\_series(:start\_date, :end\_date, :query\_interval::interval)::date + :query\_interval::interval - INTERVAL ‘1 DAY’)::date AS period\_end  
),  
poll\_votes\_with\_topics AS (  
SELECT  
pv.user\_id,  
po.poll\_id,  
pl.post\_id,  
p.topic\_id  
FROM poll\_votes pv  
JOIN poll\_options po ON po.id = pv.poll\_option\_id  
JOIN polls pl ON pl.id = po.poll\_id  
JOIN posts p ON p.id = pl.post\_id  
WHERE pv.created\_at \>= (SELECT MIN(period\_start) FROM query\_periods)  
AND pv.created\_at \<= (SELECT MAX(period\_end) FROM query\_periods)  
),  
users\_who\_posted AS (  
SELECT DISTINCT  
posts.user\_id,  
posts.topic\_id  
FROM posts  
WHERE posts.created\_at \>= (SELECT MIN(period\_start) FROM query\_periods)  
AND posts.created\_at \<= (SELECT MAX(period\_end) FROM query\_periods)  
),  
final AS (  
SELECT  
u.username,  
ue.email,  
t.title  
FROM poll\_votes\_with\_topics pvt  
JOIN users u ON u.id = pvt.user\_id  
LEFT JOIN users\_who\_posted uwp  
ON uwp.user\_id = pvt.user\_id AND uwp.topic\_id = pvt.topic\_id  
LEFT JOIN user\_emails ue ON ue.user\_id = u.id AND ue.primary = true  
JOIN topics t ON t.id = pvt.topic\_id  
WHERE uwp.user\_id IS NULL  
)

SELECT DISTINCT username, email, title  
FROM final  
ORDER BY username;
