Skip to content

Commit e9bc524

Browse files
committed
refactor: news:upsert タスクをさらに簡素化
- raw 変数を削除して直接 entries に代入 - ['news'] || [] の不要な処理を削除 - YAMLファイルが配列を直接返すため || [] も不要 - 2行削減でより直接的な実装に
1 parent fabc604 commit e9bc524

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/tasks/news.rake

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

1313
# 既存の news.yml を読み込み
1414
news_yaml_path = Rails.root.join('db', 'news.yml')
15-
existing_news = YAML.safe_load(File.read(news_yaml_path))['news']
15+
existing_news = YAML.safe_load File.read(news_yaml_path)
1616

1717
# テスト/ステージング環境ではサンプルファイル、本番は実サイトのフィード
1818
DOJO_NEWS_FEED = 'https://news.coderdojo.jp/feed/'
@@ -102,9 +102,7 @@ namespace :news do
102102
logger.info "==== START news:upsert ===="
103103

104104
yaml_path = Rails.root.join('db', 'news.yml')
105-
raw = YAML.safe_load(File.read(yaml_path))
106-
107-
entries = raw['news'] || []
105+
entries = YAML.safe_load File.read(yaml_path)
108106
new_count = 0
109107
updated_count = 0
110108

0 commit comments

Comments
 (0)