-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* id saved from response + rename spec file * spec test fix * linting * Update lib/inferno/dsl/fhir_resource_validation.rb Co-authored-by: Dylan Hall <dehall@mitre.org> * db + repo insert conflict, sorted options, idx fix * validator job fix + more tests 8fb8107 * unit test clean up --------- Co-authored-by: Dylan Hall <dehall@mitre.org>
- Loading branch information
Showing
10 changed files
with
302 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Sequel.migration do | ||
change do | ||
create_table :validator_sessions do | ||
column :id, String, primary_key: true, null: false, size: 36 | ||
column :validator_session_id, String, null: false, size: 255 | ||
column :test_suite_id, String, null: false, size: 255 | ||
column :validator_name, String, null: false, size: 255 | ||
column :suite_options, String, text: true | ||
column :last_accessed, DateTime, null: false | ||
index [:validator_session_id], unique: true | ||
index [:test_suite_id, :validator_name, :suite_options], unique: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Inferno | ||
module Entities | ||
class ValidatorSession < Entity | ||
ATTRIBUTES = [ | ||
:id, | ||
:created_at, | ||
:updated_at, | ||
:validator_session_id, | ||
:test_suite_id, | ||
:validator_name, | ||
:suite_options, | ||
:validator_index | ||
].freeze | ||
|
||
include Inferno::Entities::Attributes | ||
|
||
def initialize(params) | ||
super(params, ATTRIBUTES) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'base62-rb' | ||
require_relative 'repository' | ||
|
||
module Inferno | ||
module Repositories | ||
class ValidatorSessions < Repository | ||
def save(params) | ||
validator_session_id = params[:validator_session_id] | ||
validator_name = params[:validator_name] | ||
test_suite_id = params[:test_suite_id] | ||
raw_suite_options = params[:suite_options] | ||
time = Time.now | ||
|
||
suite_options = | ||
if raw_suite_options.blank? | ||
'[]' | ||
else | ||
raw_suite_options.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: "#{validator_session_id}_#{validator_name}", | ||
validator_session_id:, | ||
test_suite_id:, | ||
validator_name:, | ||
suite_options:, | ||
last_accessed: time | ||
) | ||
end | ||
|
||
def find_validator_session_id(test_suite_id, validator_name, suite_options) | ||
suite_options = suite_options.nil? ? '[]' : suite_options.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 | ||
|
||
class Model < Sequel::Model(db) | ||
def before_save | ||
time = Time.now | ||
self.last_accessed ||= time | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.