Class: Inferno::Repositories::ValidatorSessions
- Inherits:
-
Repository
- Object
- Repository
- Inferno::Repositories::ValidatorSessions
- Defined in:
- lib/inferno/repositories/validator_sessions.rb
Defined Under Namespace
Classes: Model
Instance Method Summary collapse
- #find_validator_session_id(test_suite_id, validator_name, suite_options) ⇒ Object
- #save(params) ⇒ Object
Methods inherited from Repository
#add_non_db_entities, #build_entity, #create, db, #db_params, #entity_class, #entity_class_name, #find, #handle_non_db_params, #non_db_params, table_name, #update
Instance Method Details
#find_validator_session_id(test_suite_id, validator_name, suite_options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/inferno/repositories/validator_sessions.rb', line 39 def find_validator_session_id(test_suite_id, validator_name, ) = .nil? ? '[]' : .sort.to_s session = self.class::Model .find(test_suite_id:, validator_name:, suite_options:) return nil if session.nil? time = Time.now session.update(last_accessed: time) session[:validator_session_id] end |
#save(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inferno/repositories/validator_sessions.rb', line 7 def save(params) validator_session_id = params[:validator_session_id] validator_name = params[:validator_name] test_suite_id = params[:test_suite_id] = params[:suite_options] time = Time.now = if .blank? '[]' else .sort.to_s end db.insert_conflict( target: [:test_suite_id, :suite_options, :validator_name], update: { validator_session_id:, test_suite_id:, suite_options:, validator_name: } ).insert( id: SecureRandom.uuid, validator_session_id:, test_suite_id:, validator_name:, suite_options:, last_accessed: time ) end |