Skip to content

Commit

Permalink
refactor: rename and add comments to clarify variables
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHulme committed Mar 7, 2024
1 parent 0680cdd commit ebb8530
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
44 changes: 28 additions & 16 deletions app/controllers/pipeline_progress_overview_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,39 @@ def show

# Pipeline details

# hash of pipelines by group
# ["scRNA Core Cell Extraction Entry", "scRNA Core Cell Extraction Seq", "scRNA Core Cell Extraction Spare"]
@pipelines_for_group = Settings.pipelines.retrieve_pipeline_config_for_group(@pipeline_group_name)

# list of group-purposes in order
@ordered_purpose_list = Settings.pipelines.combine_and_order_pipelines(@pipelines_for_group)

# purpose_pipeline_map is a hash of hashes, like:
# "Purpose 2" => {
# "Pipeline A" => {
# "parent" => "Purpose 1",
# "child" => "Purpose 3"
# },
# "Pipeline B" => {
# "parents" => "Purpose 1",
# "child" => nil
# ["LRC Blood Vac", "LRC Blood Aliquot", "LRC Blood Bank", "LRC PBMC Bank", "LRC Bank Seq", "LRC Bank Spare"]
@ordered_purpose_names = Settings.pipelines.combine_and_order_pipelines(@pipelines_for_group)

# {
# 'LRC Blood Vac' => {
# 'scRNA Core Cell Extraction Entry' => {
# parent: nil,
# child: 'LRC Blood Aliquot'
# }
# },
# 'LRC Blood Aliquot' => {
# 'scRNA Core Cell Extraction Entry' => {
# parent: 'LRC Blood Vac',
# child: 'LRC Blood Bank'
# }
@purpose_pipeline_map = Settings.pipelines.purpose_to_pipelines_map(@ordered_purpose_list, @pipelines_for_group)
@ordered_purposes_for_pipelines = order_purposes_for_pipelines(@pipelines_for_group)
# },
# ...
# }
@purpose_pipeline_details =
Settings.pipelines.purpose_to_pipelines_map(@ordered_purpose_names, @pipelines_for_group)

# {
# 'scRNA Core Cell Extraction Entry' => ['LRC Blood Vac', 'LRC Blood Aliquot', 'LRC Blood Bank'],
# 'scRNA Core Cell Extraction Seq' => ['LRC Blood Bank', 'LRC PBMC Bank', 'LRC Bank Seq'],
# 'scRNA Core Cell Extraction Spare' => ['LRC PBMC Bank', 'LRC Bank Spare']
# }
@ordered_purpose_names_for_pipelines = order_purposes_for_pipelines(@pipelines_for_group)

# Labware results
@labware = compile_labware_for_purpose(@ordered_purpose_list, page_size, @from_date, @ordered_purpose_list)
@labware = compile_labware_for_purpose(@ordered_purpose_names, page_size, @from_date, @ordered_purpose_names)
end

def from_date(params)
Expand Down
5 changes: 3 additions & 2 deletions app/models/pipeline_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def active_pipelines_for(labware)
end

# For the given pipeline group
# return a object with key: group, and value: list of the pipeline names in that group
# e.g {"Bespoke Chromium 3pv2"=>["Bespoke Chromium 3pv2", "Bespoke Chromium 3pv2 MX"]}
# return a list of the pipeline names in that group
# e.g "Bespoke Chromium 3pv2"
# =>["Bespoke Chromium 3pv2", "Bespoke Chromium 3pv2 MX"]
def retrieve_pipeline_config_for_group(pipeline_group)
@list.select { |pipeline| pipeline.pipeline_group == pipeline_group }.map(&:name)
end
Expand Down
18 changes: 9 additions & 9 deletions app/views/pipeline_progress_overview/_purpose_graph.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# @return [Boolean] Returns true if the pipeline is found in the keys of the purpose's pipeline map, false otherwise.
def purpose_is_in_pipeline(pipeline_name, purpose_name)
@purpose_pipeline_map[purpose_name].keys.include?(pipeline_name)
@purpose_pipeline_details[purpose_name].keys.include?(pipeline_name)
end

# Checks if the first purpose in a pipeline has occurred.
Expand All @@ -18,10 +18,10 @@
#
# @return [Boolean] Returns true if the purpose is the first in the pipeline and has occurred, false otherwise.
def pipeline_first_purpose_has_occurred(pipeline_name, purpose_name)
first_purpose_in_pipeline = @ordered_purposes_for_pipelines[pipeline_name].first
first_purpose_in_pipeline = @ordered_purpose_names_for_pipelines[pipeline_name].first

# get list of purposes prior to the given purpose
purposes_prior_to_purpose = @ordered_purpose_list[0..@ordered_purpose_list.index(purpose_name)]
purposes_prior_to_purpose = @ordered_purpose_names[0..@ordered_purpose_names.index(purpose_name)]

# has the first purpose in the pipeline occurred?
purposes_prior_to_purpose.include?(first_purpose_in_pipeline)
Expand All @@ -34,10 +34,10 @@
#
# @return [Boolean] Returns true if the purpose is the last in the pipeline and has not occurred, false otherwise.
def pipeline_last_purpose_is_still_to_occur(pipeline_name, purpose_name)
last_purpose_in_pipeline = @ordered_purposes_for_pipelines[pipeline_name].last
last_purpose_in_pipeline = @ordered_purpose_names_for_pipelines[pipeline_name].last

# get list of purposes after the given purpose
purposes_after_purpose = @ordered_purpose_list[@ordered_purpose_list.index(purpose_name)..-1]
purposes_after_purpose = @ordered_purpose_names[@ordered_purpose_names.index(purpose_name)..-1]

# has the last purpose in the pipeline occurred?
purposes_after_purpose.include?(last_purpose_in_pipeline)
Expand All @@ -50,11 +50,11 @@
end

def is_first_purpose_in_pipeline(pipeline_name, purpose_name)
@ordered_purposes_for_pipelines[pipeline_name].first == purpose_name
@ordered_purpose_names_for_pipelines[pipeline_name].first == purpose_name
end

def is_last_purpose_in_pipeline(pipeline_name, purpose_name)
@ordered_purposes_for_pipelines[pipeline_name].last == purpose_name
@ordered_purpose_names_for_pipelines[pipeline_name].last == purpose_name
end

def graph_classes(pipeline_name, purpose_name)
Expand All @@ -68,8 +68,8 @@
# "parents" => "Purpose 1",
# "child" => nil
# }
parent_purpose_name = @purpose_pipeline_map.dig(pipeline_name, purpose_name, 'parent')
child_purpose_name = @purpose_pipeline_map.dig(pipeline_name, purpose_name, 'child')
parent_purpose_name = @purpose_pipeline_details.dig(pipeline_name, purpose_name, 'parent')
child_purpose_name = @purpose_pipeline_details.dig(pipeline_name, purpose_name, 'child')

# provide spacing
classes = ['pipeline']
Expand Down
2 changes: 1 addition & 1 deletion app/views/pipeline_progress_overview/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<h3 class="text-center">Purposes</h3>

<!-- purpose cards, showing counts of labware for each state -->
<% @ordered_purpose_list.each do |purpose_name| %>
<% @ordered_purpose_names.each do |purpose_name| %>
<div class="stacker">
<%= render partial: 'purpose_graph', locals: { purpose_name: purpose_name } %>
<%= render partial: 'purpose_card', locals: { purpose_name: purpose_name } %>
Expand Down

0 comments on commit ebb8530

Please sign in to comment.