<commit_before>require "faraday"
require "daimon_skycrawlers/filter/base"

module DaimonSkycrawlers
  module Filter
    class UpdateChecker < Base
      def call(url)
        page = storage.find(url)
        return true unless page
        headers = Faraday.head(url)
        return false if headers["etag"] && page.etag && headers["etag"] == page.etag
        return false if headers["last-modified"].nil? && page.last_modified_at.nil?
        return false if headers["last-modified"] <= page.last_modified_at
        true
      end
    end
  end
end<commit_msg>Use specified connection to check update<commit_after>require "faraday"
require "daimon_skycrawlers/filter/base"

module DaimonSkycrawlers
  module Filter
    class UpdateChecker < Base
      def call(url, connection: nil)
        page = storage.find(url)
        return true unless page
        if connection
          headers = connection.head(url)
        else
          headers = Faraday.head(url)
        end
        return false if headers["etag"] && page.etag && headers["etag"] == page.etag
        return false if headers["last-modified"].nil? && page.last_modified_at.nil?
        return false if headers["last-modified"] <= page.last_modified_at
        true
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09365079365079365, 'fraction_numerical': 0.0, 'mean_word_length': 2.730769230769231, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4884402', 'n_tokens_mistral': 370, 'n_tokens_neox': 365, 'n_words': 98}