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:
copilot-swe-agent[bot] 2026-03-14 08:18:54 +00:00
parent 92a1c53840
commit 1fd53e0ae4
2 changed files with 3 additions and 3 deletions

View File

@ -30,13 +30,13 @@ jobs:
if [ -f "$CACHE_FILE" ]; then if [ -f "$CACHE_FILE" ]; then
CACHE_DATE=$(jq -r '.date // ""' "$CACHE_FILE" 2>/dev/null || echo "") CACHE_DATE=$(jq -r '.date // ""' "$CACHE_FILE" 2>/dev/null || echo "")
if [ "$CACHE_DATE" != "$TODAY" ]; then if [ "$CACHE_DATE" != "$TODAY" ]; then
echo '{"date":"","records":[]}' > "$CACHE_FILE" echo "{\"date\":\"$TODAY\",\"records\":[]}" > "$CACHE_FILE"
echo "✅ 公告栏缓存已清空(旧日期: $CACHE_DATE)" echo "✅ 公告栏缓存已清空(旧日期: $CACHE_DATE)"
else else
echo "📌 公告栏缓存日期匹配今天 ($TODAY),无需清空" echo "📌 公告栏缓存日期匹配今天 ($TODAY),无需清空"
fi fi
else else
echo '{"date":"","records":[]}' > "$CACHE_FILE" echo "{\"date\":\"$TODAY\",\"records\":[]}" > "$CACHE_FILE"
echo "✅ 创建新的公告栏缓存文件" echo "✅ 创建新的公告栏缓存文件"
fi fi

View File

@ -194,7 +194,7 @@ function appendToCache(cache, newEntries) {
const existingKeys = new Set(cache.records.map(r => r.key)); const existingKeys = new Set(cache.records.map(r => r.key));
let added = 0; let added = 0;
for (const e of newEntries) { 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)) { if (!existingKeys.has(key)) {
existingKeys.add(key); existingKeys.add(key);
cache.records.push({ cache.records.push({