```ruby
module FeedCrawler
  class UpdateYoutubeVideos
    include Sidekiq::Worker
    sidekiq_options queue: :parse

    def perform(feed_id)
      feed = Feed.find(feed_id)
      entries = feed.entries
      ids = entries.map { |entry| entry.data.dig("youtube_video_id") }
      embeds = Embed.youtube_video.where(provider_id: ids).index_by(&:provider_id)
      entries.map do |entry|
        id = entry.data.dig("youtube_video_id")
        if embed = embeds[id]
          unless embed.duration_in_seconds == 0
            entry.update(embed_duration: embed.duration_in_seconds)
          end
        end
      end
    end
  end
end```

Make sure data is available.
user
```ruby
module FeedCrawler
  class UpdateYoutubeVideos
    include Sidekiq::Worker
    sidekiq_options queue: :parse

    def perform(feed_id)
      feed = Feed.find(feed_id)
      entries = feed.entries
      ids = entries.flat_map { |entry| entry.data&.dig("youtube_video_id") }
      embeds = Embed.youtube_video.where(provider_id: ids).index_by(&:provider_id)
      entries.map do |entry|
        id = entry.data&.dig("youtube_video_id")
        if embed = embeds[id]
          unless embed.duration_in_seconds == 0
            entry.update(embed_duration: embed.duration_in_seconds)
          end
        end
      end
    end
  end
end```
assistant