Dashboard New Posts statistics broken

Hi all,

since one of the last upgrades one or two weeks ago the new posts statistics on the dashboard is broken here. It does not show anything anymore. Is this a problem just for me or a common bug? I did not find anything through search here.

Regards

Sorry, can you clarify, are you saying these graphs are not working?

When did you update your instance last, can you update it now?

Sorry for being unclear, here is a screenshot:

I updated this evening to 05685d430f.

If I recall right, it is for about one of two weeks now, I upgrade every five days per so at the moment.

And yeah, not much traffic at the moment, but we have new posts. :wink: I also clicked and chose the year since today. Nothing there either.

The first thing that springs to mind is “not enough data”, but let me mention this to the staff xp team who can help debug.

1 Like

Thank you! Another screenshot, where you can see that there are new topics. So there must be new posts, too. At least as many as topics (but for sure it’s more than that here :wink:).

If you go to the full report page at https://YOURSITE.COM/admin/reports/posts?end_date=2025-02-17&start_date=2025-01-17 can you get it to show you any data, adjusting the dates/filters? Do you see any errors in the logs at https://YOURSITE.COM/logs or in the Chrome DevTools Network tab when loading this page or the dashboard?

1 Like

No, everything is empty there, too. I can also adjust start and end dates, not change.

The screenshot is of a data import interface with a message indicating that no data has been imported in the current session and buttons for incremental, daily, and monthly import options, along with import dates and category selection. (Captioned by AI)

No, none. Just some deprecation notices, not related to the stats (according to the time).

Indeed, there are errors. When I load the page, it’s 9, getting more after time.

The image displays a console log with various error messages related to scripting and fetching issues in the Chrome DevTools, such as "Uncaught TypeError", "Cannot find page" errors, as well as an example of a script being executed and some managed resources and restrictions. (Captioned by AI)

Does this help? Shall I copy-paste (text) one/all of these errors?

2 Likes

Indeed, I have encountered this situation as well.My community also fails to display the correct post count.

Not correct or nothing at all like here?

1 Like

Did a little research, it seems like the domQueryService errors are from the Bitwarden Chrome extension, they are unlikely to cause issues. The mini-profiler errors can be ignored.

The fingerprint-report error is from GitHub - discourse/discourse-fingerprint: A plugin that computes user fingerprints to help administrators combat internet trolls., and while it is an issue that we need to fix it doesn’t seem to prevent the Posts report from loading for me locally.

That body_tag_1.js file other people seem to have issues with sometimes on Discourse Lost ability to scroll through HA community site - community-feedback - Home Assistant Community . Do you have any Adblockers? If so try disabling them. If not or that doesn’t work, try enabling Safe Mode Using Safe Mode to troubleshoot issues with themes and plugins and seeing if you can load the page, if you can that would indicate a plugin or theme issue.

Finally, try loading the JSON for the report and see if you get any results here:

https://YOURSITE.COM/admin/reports/bulk.json?reports[posts][facets][]=prev_period&reports[posts][start_date]=2025-01-18&reports[posts][end_date]=2025-02-18&reports[posts][limit]=50

4 Likes

I have, what’s already in Opera, which is the browser I am using on the computer. I also use Pi-hole with several blocklists.

But: These problems also occur on my iPad in the Discourse app and in other networks, including mobile data. So no ad blockers or anything like that.

I can, but not today anymore. :wink:

Sure:

{"reports":[{"type":"posts","title":"Beiträge","xaxis":"Tag","yaxis":"Anzahl neuer Beiträge","description":"Neue Beiträge, die in dieser Zeit erstellt wurden","description_link":null,"data":[],"start_date":"2025-01-18T00:00:00Z","end_date":"2025-02-18T23:59:59Z","prev_data":null,"prev_start_date":"2024-12-17T00:00:00Z","prev_end_date":"2025-01-18T00:00:00Z","prev30Days":null,"dates_filtering":true,"report_key":"reports:posts:20250118:20250218:[:prev_period]:50:4","primary_color":"rgba(113,184,254,1)","secondary_color":"rgba(113,184,254,0.1)","available_filters":[{"id":"category","type":"category","default":null}],"labels":[{"type":"date","property":"x","title":"Tag"},{"type":"number","property":"y","title":"Anzahl"}],"average":false,"percent":false,"higher_is_better":true,"modes":["chart","table"],"prev_period":0,"limit":50}]}

As this does not show anything, if I read this right, does the safe mode make sense?

1 Like

Okay thank you, that is helpful and it indicates that the data itself is missing, and not that there is some error on the frontend :thinking:

The SQL query that backs this report is fairly simple, if you have access to Data Explorer or directly to your DB you can try running and tweaking this and see if it will give you any data:

SELECT 
  COUNT(*) AS "count_all", 
  date(posts.created_at) AS "date_posts_created_at" 
FROM 
  "posts" 
  INNER JOIN "topics" ON "topics"."deleted_at" IS NULL 
  AND "topics"."id" = "posts"."topic_id" 
WHERE 
  "posts"."deleted_at" IS NULL 
  AND (
    topics.archetype <> 'private_message'
  ) 
  AND (
    posts.created_at >= '2025-02-01' 
    AND posts.created_at <= '2025-02-28'
  ) 
  AND "posts"."post_type" = 1 
GROUP BY 
  date(posts.created_at) 
ORDER BY 
  date(posts.created_at)

And here is the report code itself:

I’m afraid it’s kind of tricky to debug this further without having access to your site so I can dig around the database.

1 Like

The query in Data Explorer comes back with data:

1 Like

Sorry Roi, this got a bit lost in the cracks. I guess there must be something wrong with the report code itself? discourse/app/models/concerns/reports/posts.rb at 8596aa34c46071eb42ffbb9e19ad733d1765578e · discourse/discourse · GitHub .

Do you have access to the rails console of your site? If so try this and see if it gives you any data:

Report.find("posts", start_date: 4.weeks.ago, end_date: Time.zone.now).data

This will also output the SQL queries it runs, so might be some further clues there.

1 Like

No worries! It does not look perfect on the admin dashboard, but it is not that critical like other bugs.

Yes.

Hm, was I doing this right?

root@prometheus-discourse-sidemount:/var/www/discourse# rails c
Plugin name is 'discourse-docs', but plugin directory is named 'discourse-knowledge-explorer'
Plugin name is 'discourse-user-notes', but plugin directory is named 'discourse-staff-notes'
[1] pry(main)> Report.find("posts", start_date: 4.weeks.ago, end_date: Time.zone.now).data
=> []
[2] pry(main)>

The answer is empty. That would explain the empty box on the admin dashboard. But your wrote that there should be an SQL statement in the answer as well?

1 Like

Ah sorry maybe I only saw it because I was running it locally. Try this:

MethodProfiler.output_sql_to_stderr!
Report.find("posts", start_date: 4.weeks.ago, end_date: Time.zone.now).data

You will get a lot more noise of queries now, but the last few queries will be the ones from the report:

1 Like

Okay, a lot more noise. :wink: Is this what you are looking for or do you need more from above?

debugsql (sql): SELECT COUNT(*) AS "count_all", date(posts.created_at) AS "date_posts_created_at" FROM "posts" INNER JOIN "topics" ON "topics"."deleted_at" IS NULL AND "topics"."id" = "posts"."topic_id" WHERE "posts"."deleted_at" IS NULL AND (topics.archetype <> 'private_message') AND NOT ((topics.category_id IN (NULL))) AND (posts.created_at >= '2025-02-03 06:00:45.160432' AND posts.created_at <= '2025-03-03 06:00:45.160586') AND "posts"."post_type" = 1 GROUP BY date(posts.created_at) ORDER BY date(posts.created_at)
debugsql (sec): 0.001
debugsql (sql): SELECT "category_custom_fields"."category_id" FROM "category_custom_fields" WHERE "category_custom_fields"."name" = 'private_topics_enabled'
debugsql (sec): 0.0
debugsql (sql): SELECT COUNT(*) FROM "posts" INNER JOIN "topics" ON "topics"."deleted_at" IS NULL AND "topics"."id" = "posts"."topic_id" WHERE "posts"."deleted_at" IS NULL AND (topics.archetype <> 'private_message') AND NOT ((topics.category_id IN (NULL))) AND "posts"."post_type" = 1
debugsql (sec): 0.0
debugsql (sql): SELECT COUNT(*) FROM "posts" INNER JOIN "topics" ON "topics"."deleted_at" IS NULL AND "topics"."id" = "posts"."topic_id" WHERE "posts"."deleted_at" IS NULL AND (topics.archetype <> 'private_message') AND NOT ((topics.category_id IN (NULL))) AND "posts"."post_type" = 1 AND (posts.created_at >= '2025-01-04 06:00:45.160432' and posts.created_at < '2025-02-03 06:00:45.160432')
debugsql (sec): 0.0
debugsql (sql): COMMIT
debugsql (sec): 0.0
=> []
1 Like

Yes that is what I need :slight_smile: The part that jumps out at me is AND NOT ((topics.category_id IN (NULL))); I don’t have that in the query I show in the screenshot above. This would exclude all topics without a category from the count, which depending on your forum setup could be a lot?

I’m not seeing in the code where that comes from. Next step I would try doing this in Data Explorer:

SELECT 
  COUNT(*) AS "count_all", 
  date(posts.created_at) AS "date_posts_created_at" 
FROM 
  "posts" 
  INNER JOIN "topics" ON "topics"."deleted_at" IS NULL 
  AND "topics"."id" = "posts"."topic_id" 
WHERE 
  "posts"."deleted_at" IS NULL 
  AND (
    topics.archetype <> 'private_message'
  ) 
  AND (
    posts.created_at >= '2025-02-03 06:00:45.160432' 
    AND posts.created_at <= '2025-03-03 06:00:45.160586'
  ) 
  AND "posts"."post_type" = 1 
GROUP BY 
  date(posts.created_at) 
ORDER BY 
  date(posts.created_at)

(I removed the AND NOT clause here), and seeing if you get any result. If I run this locally I get:

 count_all | date_posts_created_at
-----------+-----------------------
         1 | 2025-02-03
         8 | 2025-02-04
         7 | 2025-02-05
         1 | 2025-02-06
         7 | 2025-02-12
         4 | 2025-02-26

Whereas if I keep the category_id clause your queries are showing I get no data.

1 Like

Works:

:sign_of_the_horns:

All our posts have a category.

Where is this additional condition coming from? :thinking:

1 Like

Yeah I’m really not sure :frowning: Long shot but it could possibly be a plugin adding/modifying something? :thinking: What plugins do you use? The first query above (the one with count_all) comes from here:

If just calling this in the console still adds that category_id IN (NULL) clause, then something is very weird:

Post.public_posts_count_per_day(4.weeks.ago, Time.zone.now)
1 Like