Add task counter to experiment card [SCI-5467]

This commit is contained in:
aignatov-bio 2021-02-10 14:50:42 +01:00
parent 8853d297ed
commit 486dae7559
4 changed files with 14 additions and 25 deletions

View file

@ -263,17 +263,13 @@
background-color: $color-alto;
}
.dates-and-img-container {
.data-row {
line-height: 26px;
}
}
.progress-bar {
background-color: $color-silver-chalice;
}
.description-cell {
width: 100%;
.description-text::after {
background: linear-gradient(to right, transparent, $color-concrete 50%);
}
@ -281,25 +277,12 @@
}
&.list {
--list-columns-number: 8;
.card.experiment-card {
.archived-date-cell {
grid-column: 5;
}
.completed-task-cell {
grid-column: 6;
}
.description-cell {
grid-column: 7;
}
.actions-cell {
grid-column: 8;
}
&:hover {
.description-text::after {
background: linear-gradient(to right, transparent, $color-alto 50%);

View file

@ -34,6 +34,12 @@ class ExperimentsOverviewService
def fetch_records
@project.experiments.joins(:project)
.left_joins(:my_modules)
.select('experiments.*')
.where('(my_modules.archived = FALSE OR my_modules.id IS NULL)')
.select('COUNT(DISTINCT my_modules.id) AS task_count')
.select('SUM(CASE WHEN my_modules.state = 1 THEN 1 ELSE 0 END) as completed_task_count')
.group('experiments.id, projects.archived_on')
end
def filter_records(records)

View file

@ -28,7 +28,7 @@
<div class="table-header-cell"><%= t('experiments.card.start_date') %></div>
<div class="table-header-cell"><%= t('experiments.card.modified_date') %></div>
<div class="table-header-cell" data-view-mode="archived"><%= t('experiments.card.archived_date') %></div>
<div class="table-header-cell"><%= t('experiments.card.completed_task') %></div>
<div class="table-header-cell" data-view-mode="active"><%= t('experiments.card.completed_task') %></div>
<div class="table-header-cell"><%= t('experiments.card.description') %></div>
<div class="table-header-cell"></div>
</div>

View file

@ -40,18 +40,18 @@
<span class="card-value"><%= l(experiment.archived_on, format: :full_date) %></span>
</div>
<% end %>
<div class="data-row" cards-render="true">
<div class="data-row" cards-render="true" data-view-mode="active">
<span class="card-label"><%= t('experiments.card.completed_task') %></span>
<span class="card-value"><%= t('experiments.card.completed_value', completed: 12, all: 16) %></span>
<span class="card-value"><%= t('experiments.card.completed_value', completed: experiment.completed_task_count, all: experiment.task_count) %></span>
</div>
</div>
<div class="workflow-img-container" cards-render="true">
</div>
</div>
<div class="completed-task-cell table-cell">
<span class="card-value" list-render="true"><%= t('experiments.card.completed_value', completed: 12, all: 16) %></span>
<div class="completed-task-cell table-cell" data-view-mode="active">
<span class="card-value" list-render="true"><%= t('experiments.card.completed_value', completed: experiment.completed_task_count, all: experiment.task_count) %></span>
<div class="progress-bar-container progress ">
<% percentage = 40 %>
<% percentage = experiment.task_count.positive? ? ((100/experiment.task_count) * experiment.completed_task_count) : 0 %>
<div class="progress-bar"
role="progressbar"
aria-valuenow="<%= percentage %>%"