Geaccepteerde Oplossingen Vraag

Hallo, ik gebruik de volgende query om geaccepteerde oplossingen deze maand te controleren. Ik zie echter geen gegevens van na maart. Bovendien komen deze cijfers niet overeen met wat wordt weergegeven in het rapport Geaccepteerde oplossingen. Kan ik hier wat begeleiding krijgen over wat ik verkeerd doe?

SELECT DISTINCT
YEAR(p.created_at), MONTH(p.created_at),
count(distinct(p.topic_id))
    FROM posts p
    JOIN posts_custom_fields pcf ON pcf.post_id = p.id
    WHERE (pcf.name = 'is_accepted_answer' AND pcf.value = 'true') AND YEAR(p.created_at) = 2025
    GROUP BY 1,2

Hi Shreyas,

Looking at the query you’ve shared, the reason you’re not seeing data past March and that the numbers in your query don’t match the Accepted Solutions Dashboard Report is because you’re using the posts_custom_fields database table, however, the Discourse Solved plugin tracks accepted solutions in using discourse_solved_solved_topics table.

As of March, 2025, there was a change that updated the Discourse Solved plugin to use the discourse_solved_solved_topics database table to determine solved topics on your Discourse site, and this table is now the source of truth for all solution data.

Here’s a corrected version of your query that will match the Accepted Solutions Report, and show you data for 2025.

Accepted solutions by month for 2025

SELECT 
    EXTRACT(YEAR FROM p.created_at) AS year,
    EXTRACT(MONTH FROM p.created_at) AS month,
    TO_CHAR(p.created_at, 'Month') AS month_name,
    COUNT(DISTINCT dst.topic_id) AS solutions_count
FROM discourse_solved_solved_topics dst
JOIN posts p ON p.id = dst.answer_post_id
WHERE p.created_at >= '2025-01-01' AND p.created_at < '2026-01-01'
GROUP BY 1, 2, 3
ORDER BY year, month

The results for this query will include:

  • All months in 2025 that have accepted solutions (not just March)
  • Numbers that match the Accepted Solutions Report because it’s using the same underlying database table
  • Date formatting using PostgreSQL’s native functions

I hope this helps you find the data you’re looking for! :slightly_smiling_face:

2 likes

Bedankt @SaraDev! Dit is nuttig. Ik zal de uitvoer van deze query controleren zodra ik discourse_solved_solved_topics in Snowflake kan opvragen.