Skip to content

Commit f0230ee

Browse files
committed
fix: 既存ニュースの差分がある場合のみ更新するよう修正
1 parent 31e3668 commit f0230ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/tasks/fetch_news.rake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ namespace :news do
7676

7777
new_items.each do |new_item|
7878
if existing_items_hash.key?(new_item['url'])
79-
# 既存アイテムの更新
8079
existing_item = existing_items_hash[new_item['url']]
81-
updated_item = existing_item.merge(new_item) # 新しい情報で更新
82-
updated_items << updated_item
80+
# タイトルまたは公開日が変わった場合のみ更新
81+
if existing_item['title'] != new_item['title'] || existing_item['published_at'] != new_item['published_at']
82+
updated_items << existing_item.merge(new_item)
83+
end
8384
else
84-
# 完全に新しいアイテム
8585
truly_new_items << new_item
8686
end
8787
end

0 commit comments

Comments
 (0)