fix: prevent future article timestamps from pinning feeds
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__, 2);
|
||||
$listsFile = $root . '/server/app/api/lists/article/ArticleLists.php';
|
||||
$databaseFile = $root . '/docker/crawler/src/storage/database.py';
|
||||
$repairFile = $root . '/docs/sql/repair_article_future_published_at.sql';
|
||||
|
||||
$listsSource = file_get_contents($listsFile);
|
||||
$databaseSource = file_get_contents($databaseFile);
|
||||
$repairSource = is_file($repairFile) ? file_get_contents($repairFile) : '';
|
||||
|
||||
$checks = [
|
||||
'文章列表定义安全发布时间排序方法' => str_contains($listsSource, 'buildSafePublishedOrder'),
|
||||
'排序会解析标准发布时间' => str_contains($listsSource, "STR_TO_DATE(published_at, '%Y-%m-%d %H:%i:%s')"),
|
||||
'排序拒绝超过两天的未来时间' => str_contains($listsSource, 'DATE_ADD(NOW(), INTERVAL 2 DAY)'),
|
||||
'异常发布时间回退到创建时间' => str_contains($listsSource, 'FROM_UNIXTIME(create_time)'),
|
||||
'采集入库前规范化发布时间' => str_contains($databaseSource, 'normalize_published_at'),
|
||||
'重复采集允许刷新有效发布时间' => str_contains($databaseSource, 'published_at=IF(VALUES(published_at)'),
|
||||
'提供幂等的历史未来时间修复 SQL' => str_contains($repairSource, 'DATE_ADD(FROM_UNIXTIME(create_time), INTERVAL 2 DAY)'),
|
||||
'历史时间修复回退到创建时间' => str_contains($repairSource, 'DATE_FORMAT(FROM_UNIXTIME(create_time)'),
|
||||
];
|
||||
|
||||
foreach ($checks as $label => $passed) {
|
||||
if (!$passed) {
|
||||
fwrite(STDERR, "FAIL: {$label}\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
echo "文章发布时间排序与采集保护静态检查通过\n";
|
||||
Reference in New Issue
Block a user