<commit_before>module Seek
  module Openbis
    # Behaviour relevant to a content blob that represents and openbis entity
    # FIXME: wanted to call ContentBlob but rails loader didn't like it and got confused
    # ... over the model ContentBlob disregarding the namespacing. Need to investigate why?
    module Blob
      # NOTE: the fact is it prepended rather than included seems to prevent the use of Concern's which
      # doesn't handle prepend
      def self.prepended(base)
        base.class_eval do
          scope :for_openbis_endpoint, (->(endpoint) { where("url LIKE 'openbis:#{endpoint.id}%'") })
        end
      end

      def openbis?
        url && valid_url? && URI.parse(url).scheme == 'openbis' && url.split(':').count == 4
      end

      def openbis_dataset
        return nil unless openbis?
        parts = url.split(':')
        endpoint = OpenbisEndpoint.find(parts[1])
        Seek::Openbis::Dataset.new(endpoint, parts[3])
      end

      def search_terms
        super | openbis_search_terms
      end

      # overide and ignore the url
      def url_search_terms
        if openbis?
          []
        else
          super
        end
      end

      private
<commit_msg>Fixed `valid_url?` without argument<commit_after>module Seek
  module Openbis
    # Behaviour relevant to a content blob that represents and openbis entity
    # FIXME: wanted to call ContentBlob but rails loader didn't like it and got confused
    # ... over the model ContentBlob disregarding the namespacing. Need to investigate why?
    module Blob
      # NOTE: the fact is it prepended rather than included seems to prevent the use of Concern's which
      # doesn't handle prepend
      def self.prepended(base)
        base.class_eval do
          scope :for_openbis_endpoint, (->(endpoint) { where("url LIKE 'openbis:#{endpoint.id}%'") })
        end
      end

      def openbis?
        url && valid_url?(url) && URI.parse(url).scheme == 'openbis' && url.split(':').count == 4
      end

      def openbis_dataset
        return nil unless openbis?
        parts = url.split(':')
        endpoint = OpenbisEndpoint.find(parts[1])
        Seek::Openbis::Dataset.new(endpoint, parts[3])
      end

      def search_terms
        super | openbis_search_terms
      end

      # overide and ignore the url
      def url_search_terms
        if openbis?
          []
        else
          super
        end
      end

      private

{'fraction_non_alphanumeric': 0.08200734394124846, 'fraction_numerical': 0.0024479804161566705, 'mean_word_length': 2.2693333333333334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5736832', 'n_tokens_mistral': 707, 'n_tokens_neox': 671, 'n_words': 233}