Statistiche Nuovi Post sulla dashboard danneggiate

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'
Loading production environment (Rails 7.2.2.1)
discourse(prod)=> Post.public_posts_count_per_day(4.weeks.ago, Time.zone.now)
  => {}
discourse(prod)=>

Molti… :wink: Preso dalla configurazione del container yaml:

https://github.com/discourse/docker_manager.git
https://github.com/discourse/discourse-adplugin.git
https://github.com/discourse/discourse-affiliate.git
https://github.com/discourse/discourse-ai.git
https://github.com/discourse/discourse-akismet.git
https://github.com/pfaffman/discourse-allow-pm-to-staff.git
https://github.com/discourse/discourse-animated-avatars.git
https://github.com/discourse/discourse-apple-auth.git
https://github.com/discourse/discourse-assign.git
https://github.com/discourse/discourse-authentication-validations.git
https://github.com/discourse/discourse-auto-deactivate.git
https://github.com/discourse/discourse-bbcode.git
https://github.com/discourse/discourse-bcc.git
https://github.com/discourse/discourse-cakeday.git
https://github.com/discourse/discourse-calendar.git
https://github.com/discourse/discourse-characters-required.git
https://github.com/discourse/discourse-chat-integration.git
https://github.com/discourse/discourse-data-explorer.git
https://github.com/discourse/discourse-fingerprint.git
https://github.com/discourse/discourse-follow.git
https://github.com/leodavidson/discourse-forcemoderation.git
https://github.com/discourse/discourse-gamification.git
https://github.com/discourse/discourse-hcaptcha.git
https://github.com/discourse/discourse-knowledge-explorer.git
https://github.com/angusmcleod/discourse-locations.git
https://github.com/discourse/discourse-login-with-amazon.git
https://github.com/discourse/discourse-math.git
https://github.com/discourse/discourse-microsoft-auth.git
https://github.com/discoursehosting/discourse-migratepassword.git
https://github.com/discourse/discourse-policy.git
https://github.com/paviliondev/discourse-post-badges-plugin.git
https://github.com/discourse/discourse-post-voting.git
https://github.com/communiteq/discourse-private-topics.git
https://github.com/discourse/discourse-push-notifications.git
https://github.com/featheredtoast/discourse-pushover-notifications.git
https://github.com/paviliondev/discourse-ratings.git
https://github.com/discourse/discourse-reactions.git
https://github.com/discourse/discourse-restricted-replies.git
https://github.com/discourse/discourse-saved-searches.git
https://github.com/discourse/discourse-shared-edits.git
https://github.com/discourse/discourse-signatures.git
https://github.com/discourse/discourse-solved.git
https://github.com/discourse/discourse-staff-alias.git
https://github.com/discourse/discourse-staff-notes.git
https://github.com/discourse/discourse-steam-login.git
https://github.com/singerscreations/discourse-stopforumspam.git
https://github.com/discourse/discourse-styleguide.git
https://github.com/discourse/discourse-subscriptions.git
https://github.com/davidtaylorhq/discourse-telegram-notifications.git
https://github.com/discourse/discourse-templates.git
https://github.com/discourse/discourse-tooltips.git
https://github.com/jannolii/discourse-topic-trade-buttons.git
https://github.com/discourse/discourse-topic-voting.git
https://github.com/discourse/discourse-translator.git
https://github.com/discourse/discourse-user-field-prompt.git
https://github.com/discourse/discourse-whos-online.git
https://github.com/discourse/discourse-yearly-review.git

A proposito, dato che anche @qingfeng1024 sta riscontrando questo problema, non sembra essere un problema personale qui. Forse può anche dirci cosa mostrano i test sopra sul/nel forum lì e anche quali plugin vengono utilizzati?

2 Mi Piace

@martin hai qualche idea su questo problema?

1 Mi Piace

No, mi dispiace, è un po’ sfuggito.

@qingfeng1024 ti succede esattamente la stessa cosa se esegui questo nella tua console rails?

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

Vedrai un output simile a questo post, puoi copiarlo e incollarlo qui per favore? Dashboard New Posts statistics broken - #18 by Roi

@kris.kotlarek Non ho avuto fortuna qui, puoi vedere se qualcosa ti salta all’occhio da questo argomento?

2 Mi Piace
root@shannon-20250121-app:/var/www/discourse# rails c
Plugin name is 'DiscourseMatheditor', but plugin directory is named 'discourse-matheditor'
Loading production environment (Rails 7.2.2.1)



discourse(prod)> MethodProfiler.output_sql_to_stderr!
Stop! This instrumentation is not intended for use in production outside of debugging scenarios. Please be sure you know what you are doing when enabling this instrumentation.
=> true




discourse(prod)> Report.find("posts", start_date: 4.weeks.ago, end_date: Time.zone.now).data
debugsql (sql): SET client_min_messages TO 'warning'
debugsql (sec): 0.0
debugsql (sql): SET standard_conforming_strings = on
debugsql (sec): 0.0
debugsql (sql): SET intervalstyle = iso_8601
debugsql (sec): 0.0
debugsql (sql): SELECT t.oid, t.typname
FROM pg_type as t
WHERE t.typname IN ('int2', 'int4', 'int8', 'oid', 'float4', 'float8', 'numeric', 'bool', 'timestamp', 'timestamptz', 'date')
debugsql (sec): 0.001
debugsql (sql): SET SESSION timezone TO 'UTC'
debugsql (sec): 0.0
debugsql (sql): SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
WHERE
  t.typname IN ('int2', 'int4', 'int8', 'oid', 'float4', 'float8', 'text', 'varchar', 'char', 'name', 'bpchar', 'bool', 'bit', 'varbit', 'date', 'money', 'bytea', 'point', 'hstore', 'json', 'jsonb', 'cidr', 'inet', 'uuid', 'xml', 'tsvector', 'macaddr', 'citext', 'ltree', 'line', 'lseg', 'box', 'path', 'polygon', 'circle', 'numeric', 'interval', 'time', 'timestamp', 'timestamptz')
debugsql (sec): 0.002
debugsql (sql): SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
WHERE
  t.typtype IN ('r', 'e', 'd')
debugsql (sec): 0.001
debugsql (sql): SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
WHERE
  t.typelem IN (16, 17, 18, 19, 20, 21, 23, 25, 26, 114, 142, 600, 601, 602, 603, 604, 628, 700, 701, 718, 790, 829, 869, 650, 1042, 1043, 1082, 1083, 1114, 1184, 1186, 1560, 1562, 1700, 2950, 3614, 3802, 16924, 88307, 88314, 106343, 106350, 13223, 13226, 13228, 13234, 13236, 3904, 3906, 3908, 3910, 3912, 3926)
debugsql (sec): 0.001
debugsql (sql): SELECT a.attname, format_type(a.atttypid, a.atttypmod),
       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
       c.collname, col_description(a.attrelid, a.attnum) AS comment,
       attidentity AS identity,
       attgenerated as attgenerated
  FROM pg_attribute a
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  LEFT JOIN pg_type t ON a.atttypid = t.oid
  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
 WHERE a.attrelid = '"themes"'::regclass
   AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum
debugsql (sec): 0.002
debugsql (sql): SHOW max_identifier_length
debugsql (sec): 0.0
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT a.attname
  FROM (
         SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
           FROM pg_index
          WHERE indrelid = '"themes"'::regclass
            AND indisprimary
       ) i
  JOIN pg_attribute a
    ON a.attrelid = i.indrelid
   AND a.attnum = i.indkey[i.idx]
 ORDER BY i.idx
debugsql (sec): 0.008
debugsql (sql): SELECT "themes".* FROM "themes" WHERE "themes"."id" = 2 ORDER BY "themes"."id" ASC LIMIT 1
debugsql (sec): 0.0
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT a.attname
  FROM (
         SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
           FROM pg_index
          WHERE indrelid = '"color_schemes"'::regclass
            AND indisprimary
       ) i
  JOIN pg_attribute a
    ON a.attrelid = i.indrelid
   AND a.attnum = i.indkey[i.idx]
 ORDER BY i.idx
debugsql (sec): 0.008
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT a.attname, format_type(a.atttypid, a.atttypmod),
       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
       c.collname, col_description(a.attrelid, a.attnum) AS comment,
       attidentity AS identity,
       attgenerated as attgenerated
  FROM pg_attribute a
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  LEFT JOIN pg_type t ON a.atttypid = t.oid
  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
 WHERE a.attrelid = '"color_schemes"'::regclass
   AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum
debugsql (sec): 0.001
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT "color_schemes".* FROM "color_schemes" WHERE (color_schemes.id NOT IN (SELECT color_scheme_id FROM theme_color_schemes)) AND "color_schemes"."id" = 5 LIMIT 1
debugsql (sec): 0.001
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT a.attname
  FROM (
         SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
           FROM pg_index
          WHERE indrelid = '"color_scheme_colors"'::regclass
            AND indisprimary
       ) i
  JOIN pg_attribute a
    ON a.attrelid = i.indrelid
   AND a.attnum = i.indkey[i.idx]
 ORDER BY i.idx
debugsql (sec): 0.008
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT a.attname, format_type(a.atttypid, a.atttypmod),
       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
       c.collname, col_description(a.attrelid, a.attnum) AS comment,
       attidentity AS identity,
       attgenerated as attgenerated
  FROM pg_attribute a
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  LEFT JOIN pg_type t ON a.atttypid = t.oid
  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
 WHERE a.attrelid = '"color_scheme_colors"'::regclass
   AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum
debugsql (sec): 0.001
debugsql (sql): ;
debugsql (sec): 0.0
debugsql (sql): SELECT "color_scheme_colors".* FROM "color_scheme_colors" WHERE "color_scheme_colors"."color_scheme_id" = 5 ORDER BY id ASC
debugsql (sec): 0.001
debugsql (sql): BEGIN
debugsql (sec): 0.0
debugsql (sql): SET TRANSACTION READ ONLY
debugsql (sec): 0.002
debugsql (sql): SET LOCAL statement_timeout = 20000
debugsql (sec): 0.0
debugsql (sql): SELECT a.attname, format_type(a.atttypid, a.atttypmod),
       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
       c.collname, col_description(a.attrelid, a.attnum) AS comment,
       attidentity AS identity,
       attgenerated as attgenerated
  FROM pg_attribute a
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  LEFT JOIN pg_type t ON a.atttypid = t.oid
  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
 WHERE a.attrelid = '"posts"'::regclass
   AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum
debugsql (sql): SET client_min_messages TO 'warning'
debugsql (sec): 0.0
debugsql (sql): SET standard_conforming_strings = on
debugsql (sec): 0.0
debugsql (sql): SET intervalstyle = iso_8601
debugsql (sec): 0.0
debugsql (sql): SELECT t.oid, t.typname
FROM pg_type as t
WHERE t.typname IN ('int2', 'int4', 'int8', 'oid', 'float4', 'float8', 'numeric', 'bool', 'timestamp', 'timestamptz', 'date')
debugsql (sec): 0.003
debugsql (sql): SELECT a.attname, format_type(a.atttypid, a.atttypmod),
       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
       c.collname, col_description(a.attrelid, a.attnum) AS comment,
       attidentity AS identity,
       attgenerated as attgenerated
  FROM pg_attribute a
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  LEFT JOIN pg_type t ON a.atttypid = t.oid
  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
 WHERE a.attrelid = '"category_custom_fields"'::regclass
   AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum
debugsql (sec): 0.005
debugsql (sql): SET SESSION timezone TO 'UTC'
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.001
debugsql (sql): SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
WHERE
  t.typname IN ('int2', 'int4', 'int8', 'oid', 'float4', 'float8', 'text', 'varchar', 'char', 'name', 'bpchar', 'bool', 'bit', 'varbit', 'date', 'money', 'bytea', 'point', 'hstore', 'json', 'jsonb', 'cidr', 'inet', 'uuid', 'xml', 'tsvector', 'macaddr', 'citext', 'ltree', 'line', 'lseg', 'box', 'path', 'polygon', 'circle', 'numeric', 'interval', 'time', 'timestamp', 'timestamptz')
debugsql (sec): 0.001
debugsql (sql): SELECT a.attname
  FROM (
         SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
           FROM pg_index
          WHERE indrelid = '"topics"'::regclass
            AND indisprimary
       ) i
  JOIN pg_attribute a
    ON a.attrelid = i.indrelid
   AND a.attnum = i.indkey[i.idx]
 ORDER BY i.idx
debugsql (sec): 0.002
debugsql (sql): SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
WHERE
  t.typtype IN ('r', 'e', 'd')
debugsql (sec): 0.001
debugsql (sql): SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
FROM pg_type as t
LEFT JOIN pg_range as r ON oid = rngtypid
WHERE
  t.typelem IN (16, 17, 18, 19, 20, 21, 23, 25, 26, 114, 142, 600, 601, 602, 603, 604, 628, 700, 701, 718, 790, 829, 869, 650, 1042, 1043, 1082, 1083, 1114, 1184, 1186, 1560, 1562, 1700, 2950, 3614, 3802, 16924, 88307, 88314, 106343, 106350, 13223, 13226, 13228, 13234, 13236, 3904, 3906, 3908, 3910, 3912, 3926)
debugsql (sec): 0.001
debugsql (sec): 0.009
debugsql (sql): SELECT a.attname
  FROM (
         SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
           FROM pg_index
          WHERE indrelid = '"posts"'::regclass
            AND indisprimary
       ) i
  JOIN pg_attribute a
    ON a.attrelid = i.indrelid
   AND a.attnum = i.indkey[i.idx]
 ORDER BY i.idx
debugsql (sec): 0.007
debugsql (sql): SELECT a.attname, format_type(a.atttypid, a.atttypmod),
       pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
       c.collname, col_description(a.attrelid, a.attnum) AS comment,
       attidentity AS identity,
       attgenerated as attgenerated
  FROM pg_attribute a
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
  LEFT JOIN pg_type t ON a.atttypid = t.oid
  LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
 WHERE a.attrelid = '"topics"'::regclass
   AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum
debugsql (sec): 0.002
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-03-03 06:42:19.865947' AND posts.created_at <= '2025-03-31 06:42:19.866261') AND "posts"."post_type" = 1 GROUP BY date(posts.created_at) ORDER BY date(posts.created_at)
debugsql (sec): 0.002
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-02-01 06:42:19.865947' and posts.created_at < '2025-03-03 06:42:19.865947')
debugsql (sec): 0.0
debugsql (sql): COMMIT
debugsql (sec): 0.0
=> []
discourse(prod)> 

The above is the output from my console.

I have installed several plugins; however, after entering safe mode in the browser, the backend still does not display the post count. I am uncertain where the issue lies, as all other statistics appear to be functioning normally—only the post count yields no results whatsoever.

2 Mi Piace

Grazie! Le tue query hanno la stessa strana clausola AND NOT ((topics.category_id IN (NULL))) di cui non riesco a capire l’origine. Almeno possiamo escludere i plugin se questo accade anche in modalità provvisoria.

1 Mi Piace

Penso che questo possa essere un problema lato server che la modalità provvisoria non disabilita.

Sembra che entrambi abbiate installato il plugin Private Topics Plugin. Penso che possa essere un problema con quello. Possibilmente questo commit di gennaio? SECURITY: remove private topics category from public_posts · communiteq/discourse-private-topics@08c9668 · GitHub

4 Mi Piace

Ottima osservazione e concordo sul fatto che il plugin non dovrebbe inserire quella riga se non ci sono categorie private impostate (aggiornerò più tardi oggi).

Ma non riesco a capire come possa compromettere la dashboard?

3 Mi Piace

Non sono del tutto sicuro, ma quando installo il plugin Private Topics sul mio sito di prova posso riprodurre questo problema. Sembra che accada quando non ho nessuna categoria impostata con ‘abilita argomenti privati’ nelle impostazioni di sicurezza della categoria (anche se il plugin è installato ma disabilitato). Se imposto una categoria per avere gli argomenti privati abilitati, il mio report della dashboard viene nuovamente popolato.

Penso che possa essere che il report modificato non gradisca il valore NULL nella condizione aggiuntiva?

6 Mi Piace

Sono stato in grado di riprodurre il problema e ho effettuato il push di una correzione.

Grazie @JammyDodger, non so quanto tempo ci avrei messo per trovarlo.

(Felice di rivederti)

5 Mi Piace

Ottimo, grazie a tutti! È stato difficile da risolvere…

1 Mi Piace

Ah fantastico grazie @JammyDodger , questo mi stava facendo impazzire :zany_face:

4 Mi Piace