fix(admin): 互动数据列移除下载量统计
「互动数据」列此前有浏览/点赞/收藏/下载四项,现按要求去掉下载量, 只保留前三项。 配套清理: - render_stats_column() 去掉下载读取、历史 download_count 键回退, 以及 fa-download 渲染分支; - apply_query_args() 的排序白名单去掉 download_count; - stats_meta_key() 映射去掉该维度。 核对参考主题:其互动列(all_count)本来就只有阅读、点赞、收藏三项, 下载量是从 AKSRT 旧实现里搬过来的,不属于参考主题能力,去掉后 与 1:1 复刻目标一致。 _aksrt_res_download_count / RESOURCE_DOWNLOAD_COUNT_KEY 本身保留, 它们仍被资源相关功能使用;此处只是不再在列表列里展示。 契约测试改为断言下载项已消失,并删掉因此不再使用的 domain 变量。 验证:node --test tests/widget-system/*.test.cjs 445 项全部通过; php -l 无语法错误。
This commit is contained in:
@@ -7,7 +7,6 @@ const root = path.resolve(__dirname, '../..')
|
||||
const read = file => fs.readFileSync(path.join(root, file), 'utf8')
|
||||
|
||||
const list = read('src/Admin/Native/PostListEnhance.php')
|
||||
const domain = read('src/Core/DomainModel.php')
|
||||
const tags = read('inc/helpers/aksrt-frontend-tags.php')
|
||||
const pay = read('inc/helpers/aksrt-pay.php')
|
||||
|
||||
@@ -49,8 +48,8 @@ test('sales column renders pay type, price and both sales counts', () => {
|
||||
|
||||
test('interaction counts are read from the keys the theme actually writes', () => {
|
||||
// 计数一律落在这几个 meta key 上:aksrt_post_views / _aksrt_like_count /
|
||||
// _aksrt_favorite_count / _aksrt_res_download_count。列回调只能用同一套键,
|
||||
// 否则全列恒为 0。旧实现读 'views' / 'like' / 'favorite',仓库里没有任何写入方。
|
||||
// _aksrt_favorite_count。列回调只能用同一套键,否则全列恒为 0。
|
||||
// 互动数据不做下载量统计,因此不再读取任何 download 键。
|
||||
assert.match(tags, /'_aksrt_like_count'/)
|
||||
assert.match(tags, /'_aksrt_favorite_count'/)
|
||||
assert.match(tags, /'aksrt_post_views'/)
|
||||
@@ -59,15 +58,17 @@ test('interaction counts are read from the keys the theme actually writes', () =
|
||||
assert.match(list, /aksrt_get_post_likes\(\$post_id\)/)
|
||||
assert.match(list, /aksrt_get_post_favorites\(\$post_id\)/)
|
||||
|
||||
// 资源下载量只有 _aksrt_res_download_count 一个写入键。
|
||||
assert.match(list, /DomainModel::RESOURCE_DOWNLOAD_COUNT_KEY/)
|
||||
assert.match(domain, /RESOURCE_DOWNLOAD_COUNT_KEY\s*=\s*'_aksrt_res_download_count'/)
|
||||
|
||||
// 不得再直接读这些不存在的键('download_count' 只作为历史遗留键回退读取)。
|
||||
// 不得再直接读这些不存在的键。
|
||||
const column = list.slice(list.indexOf('private function render_stats_column'), list.indexOf('private function render_sales_column'))
|
||||
assert.doesNotMatch(column, /get_post_meta\(\$post_id, 'views'/)
|
||||
assert.doesNotMatch(column, /get_post_meta\(\$post_id, 'like'/)
|
||||
assert.doesNotMatch(column, /get_post_meta\(\$post_id, 'favorite'/)
|
||||
|
||||
// 下载量统计已移除:不得再读下载键,也不得再渲染下载项。
|
||||
assert.doesNotMatch(column, /RESOURCE_DOWNLOAD_COUNT_KEY/)
|
||||
assert.doesNotMatch(column, /'download_count'/)
|
||||
assert.doesNotMatch(column, /fa-download/)
|
||||
assert.doesNotMatch(column, /下载/)
|
||||
})
|
||||
|
||||
test('admin stats column shares the aksrt_format_number abbreviation', () => {
|
||||
@@ -81,9 +82,10 @@ test('sortable meta maps the public orderby keys to the stored keys', () => {
|
||||
assert.match(list, /'views'\s*=>\s*\\AKSRT\\Core\\DomainModel::POST_VIEW_COUNT_KEY/)
|
||||
assert.match(list, /'like'\s*=>\s*'_aksrt_like_count'/)
|
||||
assert.match(list, /'favorite'\s*=>\s*'_aksrt_favorite_count'/)
|
||||
assert.match(list, /'download_count'\s*=>\s*\\AKSRT\\Core\\DomainModel::RESOURCE_DOWNLOAD_COUNT_KEY/)
|
||||
// meta_key 必须是真实存储键,而不是用户可见的排序键。
|
||||
assert.match(list, /\$query->set\('meta_key', \$this->stats_meta_key\(\$orderby\)\)/)
|
||||
// 互动数据不统计下载量,排序映射里也不得再出现该维度。
|
||||
assert.doesNotMatch(list, /'download_count'/)
|
||||
})
|
||||
|
||||
test('every counter meta key the admin column renders has a writer', () => {
|
||||
@@ -104,9 +106,9 @@ test('every counter meta key the admin column renders has a writer', () => {
|
||||
assert.match(tags, /_aksrt_res_view_count/)
|
||||
assert.match(read('inc/helpers/aksrt-resource.php'), /RESOURCE_VIEW_COUNT_KEY|_aksrt_res_view_count/)
|
||||
|
||||
// 资源下载走普通外链,主题内没有任何写入方,所以下载项只在 >0 时出现。
|
||||
assert.match(list, /\$downloads <= 0/)
|
||||
assert.match(list, /\$legacy_downloads/)
|
||||
// 互动数据不统计下载量:列里不得再出现下载键的读取或回退逻辑。
|
||||
assert.doesNotMatch(list, /RESOURCE_DOWNLOAD_COUNT_KEY/)
|
||||
assert.doesNotMatch(list, /\$downloads/)
|
||||
})
|
||||
|
||||
test('sales volume is written by the order pipeline', () => {
|
||||
@@ -118,7 +120,7 @@ test('sales volume is written by the order pipeline', () => {
|
||||
|
||||
test('admin column icons stay behind the Font Awesome enqueue on edit.php', () => {
|
||||
assert.match(list, /admin_enqueue_scripts[\s\S]*?edit\.php[\s\S]*?aksrt_enqueue_fontawesome\(\)/)
|
||||
for (const klass of ['fa-eye', 'fa-thumbs-up', 'fa-star', 'fa-download']) {
|
||||
for (const klass of ['fa-eye', 'fa-thumbs-up', 'fa-star']) {
|
||||
assert.match(list, new RegExp(klass))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user