Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Commit

Permalink
Issue 20: Re-factor current mining into a type of mining activity
Browse files Browse the repository at this point in the history
  • Loading branch information
eacharya committed Jul 23, 2015
1 parent 8820c16 commit 567d106
Show file tree
Hide file tree
Showing 27 changed files with 460 additions and 412 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Analysis
class SetupMiningController < ApplicationController
module Analysis::MiningSetup
class ZdistFinderController < ApplicationController
include Wicked::Wizard
steps :chia_version, :videos, :zdist_threshs, :smart_filters, :create_sets
before_action :set_steps
before_action :setup_wizard

before_action :set_mining, only: [:show, :update]
before_action :set_steps_ll, only: [:show, :update]

def show
Expand Down Expand Up @@ -52,7 +52,7 @@ def finish_wizard_path
def serveChiaVersion
@chiaVersionIdLoc = @mining.chia_version_id_loc
@chiaVersionIdAnno = @mining.chia_version_id_anno
@chia_versions = ::ChiaVersion.all
@chiaVersions = ::ChiaVersion.all
end
def handleChiaVersion
chiaVersionIdLoc = params[:chia_version_id_loc].to_i
Expand Down Expand Up @@ -80,7 +80,7 @@ def handleVideos
def serveZDistThreshs
chiaVersionIdLoc = @mining.chia_version_id_loc
videoIds = @mining.video_ids
@zdistThreshs = @mining.zdist_threshs || {}
@zdistThreshs = @mining.md_zdist_finder.zdist_threshs || {}

@metricsVideo = ::Metrics::Analysis::VideosDetails.new(chiaVersionIdLoc, videoIds)
@metricsVideoDetails = @metricsVideo.getDetails
Expand All @@ -90,19 +90,18 @@ def handleZDistThreshs
videoIds = @mining.video_ids

zdistThreshs = Hash[params[:det_ids].map{ |d,z| [d.to_i, z.to_f] }]
@mining.md_zdist_finder.update(zdist_threshs: zdistThreshs)

clipSetCreator = ::Metrics::Analysis::ClipSetCreator.new(chiaVersionIdLoc, videoIds, zdistThreshs)
clipSets = clipSetCreator.getClipSets
@mining.update(
zdist_threshs: zdistThreshs,
clip_sets: clipSets
)
@mining.update(clip_sets: clipSets)
end

def serveSmartFilters
end
def handleSmartFilters
spatialIntersectionThresh = params[:spatial_intersection_thresh].to_f
@mining.update(smart_filter: {spatial_intersection_thresh: spatialIntersectionThresh})
@mining.md_zdist_finder.update(smart_filter: {spatial_intersection_thresh: spatialIntersectionThresh})
end

def serveCreateSets
Expand All @@ -114,9 +113,10 @@ def handleCreateSets
end

# Use callbacks to share common setup or constraints between actions.
def set_mining
def set_steps
session[:mining_id] ||= params[:mining_id]
@mining = ::Mining.find(session[:mining_id])
self.steps = [:chia_version, :videos, :zdist_threshs, :smart_filters, :create_sets]
end

def set_steps_ll
Expand All @@ -125,4 +125,4 @@ def set_steps_ll
@next_step = steps.index(step) == (steps.count - 1) ? nil : steps[steps.index(step) + 1]
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/analysis/minings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def set_mining

# Never trust parameters from the scary internet, only allow the white list through.
def mining_params
params.require(:mining).permit(:name, :description)
params.require(:mining).permit(:name, :description, :mtype)
end
end
end
16 changes: 10 additions & 6 deletions app/controllers/api/v1/minings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,45 @@ class MiningsController < ApplicationController

# GET api/v1/minings/show
def show
m = Jsonifiers::Mining::SetDetails.new(@miningId, @setId)
m = @mTypeModule::SetDetails.new(@mining, @setId)
render json: m.formatted.to_json
end

# GET api/v1/minings/full_localizations
def full_localizations
m = Jsonifiers::Mining::FullLocalizations.new(@miningId, @setId)
m = @mTypeModule::FullLocalizations.new(@mining, @setId)
render json: m.formatted.to_json
end

# GET api/v1/minings/full_annotations
def full_annotations
m = Jsonifiers::Mining::FullAnnotations.new(@miningId, @setId)
m = @mTypeModule::FullAnnotations.new(@mining, @setId)
render json: m.formatted.to_json
end

# GET api/v1/filters/color_map
def color_map
chiaVersion = ::Mining.find(@miningId).chiaVersionLoc
chiaVersion = @mining.chiaVersionLoc
colorMap = chiaVersion.color_map.color_map
render json: colorMap.to_json
end

# GET api/v1/filters/cell_map
def cell_map
chiaVersion = ::Mining.find(@miningId).chiaVersionLoc
chiaVersion = @mining.chiaVersionLoc
cellMap = chiaVersion.cell_map.cell_map
render json: cellMap.to_json
end

private
# Use callbacks to share common setup or constraints between actions.
def set_mining
@miningId = params['mining_id']
miningId = params['mining_id']
@setId = params['set_id']
@mining = ::Mining.find(miningId)
if States::MiningType.new(@mining).isZdistFinder?
@mTypeModule = Jsonifiers::Mining::ZdistFinder
end
end

end
Expand Down
58 changes: 0 additions & 58 deletions app/jsonifiers/mining/full_annotations.rb

This file was deleted.

65 changes: 0 additions & 65 deletions app/jsonifiers/mining/full_localizations.rb

This file was deleted.

101 changes: 0 additions & 101 deletions app/jsonifiers/mining/set_details.rb

This file was deleted.

Loading

0 comments on commit 567d106

Please sign in to comment.