fix: address code review - use full timestamp for dedup key, set today's date on cache reset
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
92a1c53840
commit
1fd53e0ae4
|
|
@ -30,13 +30,13 @@ jobs:
|
|||
if [ -f "$CACHE_FILE" ]; then
|
||||
CACHE_DATE=$(jq -r '.date // ""' "$CACHE_FILE" 2>/dev/null || echo "")
|
||||
if [ "$CACHE_DATE" != "$TODAY" ]; then
|
||||
echo '{"date":"","records":[]}' > "$CACHE_FILE"
|
||||
echo "{\"date\":\"$TODAY\",\"records\":[]}" > "$CACHE_FILE"
|
||||
echo "✅ 公告栏缓存已清空(旧日期: $CACHE_DATE)"
|
||||
else
|
||||
echo "📌 公告栏缓存日期匹配今天 ($TODAY),无需清空"
|
||||
fi
|
||||
else
|
||||
echo '{"date":"","records":[]}' > "$CACHE_FILE"
|
||||
echo "{\"date\":\"$TODAY\",\"records\":[]}" > "$CACHE_FILE"
|
||||
echo "✅ 创建新的公告栏缓存文件"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ function appendToCache(cache, newEntries) {
|
|||
const existingKeys = new Set(cache.records.map(r => r.key));
|
||||
let added = 0;
|
||||
for (const e of newEntries) {
|
||||
const key = `${e.actor}|${e.module || '—'}|${formatTimeShort(e.ts)}`;
|
||||
const key = `${e.actor}|${e.module || '—'}|${e.ts || ''}`;
|
||||
if (!existingKeys.has(key)) {
|
||||
existingKeys.add(key);
|
||||
cache.records.push({
|
||||
|
|
|
|||
Loading…
Reference in New Issue