Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Restructure models.
Browse files Browse the repository at this point in the history
  • Loading branch information
arscan committed Dec 18, 2017
1 parent 93a7df6 commit 31456cb
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.log
*.log.*
config.yml.bak
data/*
48 changes: 32 additions & 16 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,28 @@
require 'dm-migrations'


DataMapper.setup(:default, 'sqlite3:data.db')
DataMapper.setup(:default, 'sqlite3:data/data.db')

Dir.glob(File.join(File.dirname(File.absolute_path(__FILE__)),'lib','**','*.rb')).each do |file|
require file
end

class TestInstance
include DataMapper::Resource
property :id, String, key: true
property :url, String
property :name, String
property :created_at, DateTime
['lib', 'models'].each do |dir|
Dir.glob(File.join(File.dirname(File.absolute_path(__FILE__)),dir, '**','*.rb')).each do |file|
require file
end
end

#TODO clean up database stuff

DataMapper.finalize

# automatically create the post table
TestInstance.auto_migrate!
TestInstance.auto_upgrade!
TestingInstance.auto_migrate!
TestingInstance.auto_upgrade!

SequenceResult.auto_migrate!
SequenceResult.auto_upgrade!

TestResult.auto_migrate!
TestResult.auto_upgrade!

enable :sessions
set :session_secret, SecureRandom.uuid
Expand Down Expand Up @@ -59,27 +62,40 @@ class TestInstance
end

get '/instance/:id/?' do
@instance = TestInstance.get(params[:id])
@instance = TestingInstance.get(params[:id])
erb :details
end

get '/instance/:id/2/?' do
@instance = TestInstance.get(params[:id])
@instance = TestingInstance.get(params[:id])
erb :details2
end

get '/instance/:id/3/?' do
@instance = TestInstance.get(params[:id])
@instance = TestingInstance.get(params[:id])
erb :details3
end

post '/instance/?' do
id = SecureRandom.uuid
@instance = TestInstance.new(id: id, created_at: DateTime.now, url: params['fhir_server'], name: params['name'])
@instance = TestingInstance.new(id: id, created_at: DateTime.now, url: params['fhir_server'], name: params['name'])
@instance.save
redirect "/instance/#{id}/"
end

post '/instance/:id/run_test/' do

end

get '/instance/:id/redirect/:key/' do


end

get '/instance/:id/launch/:key/' do


end

# This is the primary endpoint of the app and the OAuth2 redirect URL
get '/app' do
Expand Down
1 change: 1 addition & 0 deletions data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
11 changes: 11 additions & 0 deletions models/SequenceResult.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SequenceResult
include DataMapper::Resource
property :id, Serial
property :result, String #pass fail skip
property :passed_count, Integer
property :failed_count, Integer

has n, :test_results
belongs_to :testing_instance
end

8 changes: 8 additions & 0 deletions models/TestResult.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class TestResult
include DataMapper::Resource
property :id, Serial
property :result, String #pass fail skip

belongs_to :sequence_result
end

12 changes: 12 additions & 0 deletions models/TestingInstance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class TestingInstance
include DataMapper::Resource
property :id, String, key: true
property :url, String
property :name, String
property :redirect_key, String
property :launch_key, String
property :created_at, DateTime

has n, :sequence_results
end

0 comments on commit 31456cb

Please sign in to comment.