Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-656: Show auto subsamples if they have data #817

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,15 @@ function _sub_samples()
$where = '';
$first_inner_select_where = '';
$second_inner_select_where = '';
$third_inner_select_where = '';
$args = array($this->proposalid);

if ($this->has_arg('sid')) {
$where .= ' AND s.blsampleid=:' . (sizeof($args) + 1);
$first_inner_select_where .= ' AND s.blsampleid=:' . (sizeof($args) + 2);
$second_inner_select_where .= ' AND s.blsampleid=:' . (sizeof($args) + 3);
array_push($args, $this->arg('sid'), $this->arg('sid'), $this->arg('sid'));
$third_inner_select_where .= ' AND s.blsampleid=:' . (sizeof($args) + 4);
array_push($args, $this->arg('sid'), $this->arg('sid'), $this->arg('sid'), $this->arg('sid'));
}

if ($this->has_arg('cid')) {
Expand All @@ -647,7 +649,7 @@ function _sub_samples()
}

$this->db->wait_rep_sync(true);
$ss_query_string = $this->get_sub_samples_query($where, $first_inner_select_where, $second_inner_select_where);
$ss_query_string = $this->get_sub_samples_query($where, $first_inner_select_where, $second_inner_select_where, $third_inner_select_where);
$subs = $this->db->pq($ss_query_string, $args);

$this->db->wait_rep_sync(false);
Expand Down Expand Up @@ -682,7 +684,7 @@ function _get_sub_sample()
}
}

private function get_sub_samples_query($where, $first_inner_select_where = '', $second_inner_select_where = '')
private function get_sub_samples_query($where, $first_inner_select_where = '', $second_inner_select_where = '', $third_inner_select_where = '')
{
$group_by = "";
$order_by = "";
Expand All @@ -706,22 +708,34 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
$from_query = "FROM (
SELECT ss.blsubsampleid
FROM (
SELECT s.blsampleid, max(si.blsampleimageid) AS blsampleimageid
SELECT s.blsampleid, max(si.blsampleimageid) AS blsampleimageid
FROM blsample s
INNER JOIN blsampleimage si ON si.blsampleid = s.blsampleid
WHERE 1=1 $first_inner_select_where
GROUP BY s.blsampleid
) qq
JOIN blsubsample ss ON ss.blsampleimageid = qq.blsampleimageid
WHERE ss.source = 'auto'

UNION ALL

SELECT ss.blsubsampleid
FROM blsubsample ss
LEFT JOIN blsample s on ss.blsampleid = s.blsampleid
WHERE ss.source = 'manual' $second_inner_select_where
) q JOIN blsubsample ss ON ss.blsubsampleid = q.blsubsampleid";
WHERE ss.source = 'manual' $second_inner_select_where";

// show auto generated subsamples with data collections
if ($third_inner_select_where != '') {
$from_query .= "
UNION ALL
SELECT ss.blsubsampleid
FROM blsubsample ss
LEFT JOIN blsample s on ss.blsampleid = s.blsampleid
INNER JOIN datacollection dc ON ss.blsubsampleid = dc.blsubsampleid
WHERE ss.source = 'auto' $third_inner_select_where";
}

$from_query .= ") q JOIN blsubsample ss ON ss.blsubsampleid = q.blsubsampleid";

$group_by = "GROUP BY pr.acronym,
s.name,
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/utils/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ define(['marionette', 'backgrid',
return this;
}
}),

ProjectCell: Backgrid.Cell.extend({
events: {
'click a.atp': 'addToProject',
Expand Down Expand Up @@ -232,4 +232,4 @@ define(['marionette', 'backgrid',
}

})


Loading