<commit_before># encoding: utf-8
require 'sequel'
require 'uuidtools'

module DataRepository
  module Backend
    class Sequel
      PAGE          = 1
      PER_PAGE      = 300
      ARRAY_RE      = %r{\[.*\]}

      def initialize(db=Sequel.sqlite, relation=nil)
        @db         = db
        @relation   = relation.to_sym
        ::Sequel.extension(:pagination)
        @db.extension(:connection_validator)
        # TODO: Check how to get config from here
        @db.pool.connection_validation_timeout = 900
        @db.extension :pg_array if postgres?(@db)
      end #initialize

      def collection(filter={}, available_filters=[])
        return db[relation] if filter.nil? || filter.empty?
        available_filters   = symbolize_elements(available_filters)

        filter = symbolize_keys(filter).select { |key, value|
          available_filters.include?(key)
        } unless available_filters.empty?

        db[relation].where(filter)<commit_msg>CDB-2891 Removed connetion_validator from one of the connection points. will require further research<commit_after># encoding: utf-8
require 'sequel'
require 'uuidtools'

module DataRepository
  module Backend
    class Sequel
      PAGE          = 1
      PER_PAGE      = 300
      ARRAY_RE      = %r{\[.*\]}

      def initialize(db=Sequel.sqlite, relation=nil)
        @db         = db
        @relation   = relation.to_sym
        ::Sequel.extension(:pagination)
        ::Sequel.extension(:connection_validator)
        @db.extension :pg_array if postgres?(@db)
      end #initialize

      def collection(filter={}, available_filters=[])
        return db[relation] if filter.nil? || filter.empty?
        available_filters   = symbolize_elements(available_filters)

        filter = symbolize_keys(filter).select { |key, value|
          available_filters.include?(key)
        } unless available_filters.empty?

        db[relation].where(filter)
{'fraction_non_alphanumeric': 0.10062565172054223, 'fraction_numerical': 0.008863399374348279, 'mean_word_length': 2.600375234521576, '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': '1072837', 'n_tokens_mistral': 557, 'n_tokens_neox': 537, 'n_words': 125}