<commit_before>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<commit_msg>Make sure data is available.<commit_after>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
{'fraction_non_alphanumeric': 0.0911144578313253, 'fraction_numerical': 0.0015060240963855422, 'mean_word_length': 2.712290502793296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1361271', 'n_tokens_mistral': 427, 'n_tokens_neox': 414, 'n_words': 85}