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

オープン 初心者向け
#4,856 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, typescript, wordpress

調査の方向性

src/content-helper/dashboard-page/components/posts-table/components/single-post-row.tsx:106から始め、smart-linkのビューが合計ビューとどのように解析されるかを比較してください。src/rest-api/stats/trait-post-data.php:129から返される書式設定済みの件数を確認し、ロケールごとの区切り文字を考慮してください。大きな件数でも、行にsmart-linkのビューとブーストされた割合がすべてのロケールで正しく表示されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
PHP
スター
67
フォーク
38
平均マージ
1日 5時間
マージ済み PR(30日)
79

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Parsely/wp-parsely のほかの issue

Parsely/wp-parsely の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。