Skip to content

Commit

Permalink
Merge f79c08a into 16d1de0
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed May 23, 2016
2 parents 16d1de0 + f79c08a commit cd8ee19
Show file tree
Hide file tree
Showing 27 changed files with 1,901 additions and 252 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bin/* diff=ruby eol=lf

# Ensure those won't be messed up with
*.jpg binary
*.png binary
*.data binary
*.ogg binary
*.mp3 binary
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ GEM
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
sprockets (3.6.0)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
Expand Down
7 changes: 5 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Vagrant.configure(2) do |config|
# within the machine from a port on the host machine.
config.vm.network 'forwarded_port', guest: 3000, host: 3000 # rails
config.vm.network 'forwarded_port', guest: 1236, host: 26166 # debugging
config.vm.network 'forwarded_port', guest: 5433, host: 5432 # postgres
config.vm.network 'forwarded_port', guest: 5432, guest_ip: '127.0.0.1', host: 5432 # postgres

# Create a private network, which allows host-only access to the machine.
# A private dhcp network is required for NFS to work (on Windows hosts, at least)
Expand Down Expand Up @@ -74,7 +74,10 @@ Vagrant.configure(2) do |config|
config.vm.provision 'shell', inline: <<-SHELL
sudo apt-get update
# temporary workaround for https://github.com/mitchellh/vagrant/issues/6793
sudo apt-get install -y git python-pip python-dev && sudo pip install ansible==1.9.3 && sudo cp /usr/local/bin/ansible /usr/bin/ansible
echo "Installing build tools..."
sudo apt-get install -y build-essential libffi-dev libssl-dev python-dev
echo "Installing git, pip, and ansible..."
sudo apt-get install -y git python-pip && sudo pip install ansible==1.9.3 && sudo cp /usr/local/bin/ansible /usr/bin/ansible
SHELL

config.vm.provision 'ansible_local' do |ansible|
Expand Down
15 changes: 7 additions & 8 deletions app/controllers/analysis_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'find'



=begin
Analysis endpoint definition:
- case-sensitive
Expand All @@ -8,15 +10,19 @@
- responses to get and head requests differ only in inclusion of body content
=end

# @deprecated This class will be merged into AnalysisJobsItem controller
class AnalysisController < ApplicationController
skip_authorization_check only: [:show]

# GET|HEAD /analysis_jobs/:analysis_job_id/audio_recordings/:audio_recording_id/
# GET|HEAD /analysis_jobs/:analysis_job_id/audio_recordings/:audio_recording_id/*results_path
# @deprecated
def show
# start timing request
overall_start = Time.now

fail "deprecated"

# normalise params and get access to rails request instance
request_params = CleanParams.perform(params.dup)

Expand Down Expand Up @@ -77,15 +83,8 @@ def show

end

# GET|HEAD /analysis_jobs/system
def system_all
fail NotImplementedError
end

# GET|HEAD /analysis_jobs/system/audio_recordings
def system_audio_recordings
fail NotImplementedError
end


private

Expand Down
27 changes: 26 additions & 1 deletion app/controllers/analysis_jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class AnalysisJobsController < ApplicationController
include Api::ControllerHelper

SYSTEM_JOB_ID = 'system'

# GET /analysis_jobs
def index
do_authorize_class
Expand All @@ -16,6 +18,8 @@ def index

# GET /analysis_jobs/1
def show
return system_show if is_system?

do_load_resource
do_authorize_instance

Expand Down Expand Up @@ -51,6 +55,8 @@ def create

# PUT|PATCH /analysis_jobs/1
def update
return system_mutate if is_system?

do_load_resource
do_authorize_instance

Expand All @@ -63,11 +69,17 @@ def update

# DELETE /analysis_jobs/1
def destroy
return system_mutate if is_system?

do_load_resource
do_authorize_instance

@analysis_job.destroy
add_archived_at_header(@analysis_job)

# TODO: delete pending analysis jobs from worker message queue
# TODO: change all pending analysis_job_items to :cancelled

respond_destroy
end

Expand All @@ -86,6 +98,20 @@ def filter

private

# GET|HEAD /analysis_jobs/system
def system_show
fail NotImplementedError.new
end

# PUT|PATCH|DELETE /analysis_jobs/system
def system_mutate
fail CustomErrors::MethodNotAllowedError.new('Cannot update a system job', [:post, :put, :patch, :delete])
end

def is_system?
params[:id] == 'system'
end

def analysis_job_create_params
# When Analysis jobs are created, they must have
# a script, saved search, name, and custom settings.
Expand All @@ -107,5 +133,4 @@ def analysis_job_update_params
def get_analysis_jobs
Access::Query.analysis_jobs(current_user, Access::Core.levels_allow)
end

end
Loading

0 comments on commit cd8ee19

Please sign in to comment.