<commit_before>module Ragios
  module Model
    class CouchdbMonitorModel
    
      def self.save(monitors_list) 
        begin
          Couchdb.create monitors,auth_session
        rescue CouchdbException 
        end
        monitors_list.each do |monitor|
          doc = {:database => monitors, :doc_id => monitor[:_id], :data => monitor}
          hash = Couchdb.create_doc doc,auth_session
        end
      end
    
      def self.delete(id)
        Couchdb.delete_doc({:database => monitors, :doc_id => id},auth_session)
      end
      
      def self.find(id)
        monitor = Couchdb.view({:database => monitors, :doc_id => id},auth_session) 
     end
      
      def self.update(id,options)
        doc = { :database => monitors, :doc_id => id, :data => options}   
        Couchdb.update_doc doc,auth_session
      end
      
      def self.active_monitors
        view = {:database => monitors,
                :design_doc => 'monitors',
                   :view => 'get_active_monitors',
                         :json_doc => $path_to_json + '/get_monitors.json'}
        Couchdb.find_on_fly(view,auth_session)
      end
      
      def self.all
        view = {:database => monitors,
                    :design_doc => 'monitors',
                         :view => 'get_monitors',
                          :json_doc => $path_to_json + '/get_monitors.json'}

        Couchdb.find_on_fly(view,auth_session)
      end
      
      def self.where(options)
        Couchdb.find_by({:database => monitors, options.keys[0] => options.values[0]},auth_session) 
      end      
      
      private 
      
      def self.monitors
        Ragios::CouchdbAdmin.monitors
      end
      
      def self.auth_session
        Ragios::CouchdbAdmin.session
      end
    
    end
  end
end  
<commit_msg>quick refactor and clarity<commit_after>module Ragios
  module Model
    class CouchdbMonitorModel
    
      def self.save(monitors_list) 
        begin
          Couchdb.create monitors,auth_session
        rescue CouchdbException 
        end
        monitors_list.each do |monitor|
          doc = {:database => monitors, :doc_id => monitor[:_id], :data => monitor}
          hash = Couchdb.create_doc doc,auth_session
        end
      end
    
      def self.delete(id)
        #should raise appropriate exception when monitor is not found
        Couchdb.delete_doc({:database => monitors, :doc_id => id},auth_session)
      end
      
      def self.find(id)
        #should raise appropriate exception when monitor id is not found
        monitor = Couchdb.view({:database => monitors, :doc_id => id},auth_session) 
     end
      
      def self.update(id,options)
        doc = { :database => monitors, :doc_id => id, :data => options}   
        Couchdb.update_doc doc,auth_session
      end
      
      def self.active_monitors
        view = {:database => monitors,
                :design_doc => 'monitors',
                   :view => 'get_active_monitors',
                         :json_doc => $path_to_json + '/get_monitors.json'}
        Couchdb.find_on_fly(view,auth_session)
      end
      
      def self.all
        view = {:database => monitors,
                    :design_doc => 'monitors',
                         :view => 'get_monitors',
                          :json_doc => $path_to_json + '/get_monitors.json'}

        Couchdb.find_on_fly(view,auth_session)
      end
      
      def self.where(options)
        Couchdb.find_by({:database => monitors, options.keys.first => options.values.first},auth_session) 
      end      
      
      private 
      
      def self.monitors
        Ragios::CouchdbAdmin.monitors
      end
      
      def self.auth_session
        Ragios::CouchdbAdmin.session
      end
    
    end
  end
end  

{'fraction_non_alphanumeric': 0.09460887949260043, 'fraction_numerical': 0.0005285412262156448, 'mean_word_length': 1.78104335047759, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, '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': '5610809', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1105, 'n_words': 228}