Engagement Boost misreads smart-link views that have a thousands separator

Aperta Adatta ai principianti
#4,856 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, typescript, wordpress

Direzione di ricerca

Inizia da src/content-helper/dashboard-page/components/posts-table/components/single-post-row.tsx:106 e confronta come vengono analizzate le visualizzazioni degli smart link rispetto alle visualizzazioni totali. Controlla il conteggio formattato restituito da src/rest-api/stats/trait-post-data.php:129 e tieni conto dei separatori della locale. Il lavoro è completato quando la riga mostra correttamente le visualizzazioni degli smart link e la percentuale di contenuti promossi per i conteggi elevati in tutte le locale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug Feature: Engagement Boost wp-parsely

Describe the bug

The Engagement Boost dashboard reads a post's smart-link views with Number( stats?.campaign?.views ?? 0 ) (src/content-helper/dashboard-page/components/posts-table/components/single-post-row.tsx:106). The REST API formats that value with number_format_i18n() (src/rest-api/stats/trait-post-data.php:129), so from 1,000 views on it contains the locale's thousands separator, which Number() doesn't parse:

  • "1,234" becomes NaN, as does a value with a space-like separator, as in French. The "+N" smart-link views and the "X% BOOSTED" percentage then both disappear, since their > 0 checks fail.
  • With . as the separator, as in German, "1.234" becomes 1.234. The dashboard then shows a wrong "+N" and a near-zero boost percentage.

Total views, on the line above, are parsed with .replace( /\D/g, '' ), which handles any separator.

To Reproduce

  1. Open the Engagement Boost dashboard for a post with 1,000 or more smart-link views in the selected period.
  2. The post's row shows its total views, without the "+N" smart-link views or the "BOOSTED" percentage.

Expected behavior

The dashboard shows the post's smart-link views and boost percentage, whatever their size and the site's locale.

Environment

wp-parsely 3.26.1 and current develop, any browser.

Additional context

Possible fixes: parse the value the same way as the total views, or have the REST API also return raw counts, so the client doesn't parse formatted strings.

Related: #4854 and #4855, which affect the same campaign data.

Lingua principale
PHP
Stelle
67
Fork
38
Merge medio
1g 5h
PR unite (30g)
79

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Parsely/wp-parsely

Tutte le issue di Parsely/wp-parsely

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.