Skip to content

Commit

Permalink
LIMS-1330: Use experimentTypeId if specified (#796)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Williams <[email protected]>
  • Loading branch information
ndg63276 and Mark Williams authored Jul 23, 2024
1 parent c9c51b7 commit 78a1bc4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions api/src/Database/Type/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class MySQL extends DatabaseParent {
'BLSubSample',
'PDB',
'Protein_has_PDB',
'ExperimentType',

// Stat Views
'v_logonByHour',
Expand Down
14 changes: 8 additions & 6 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ function _data_collections($single = null)

$where = '';
if ($this->arg('t') == 'sc')
$where = ' AND (dc.overlap != 0 OR dcg.experimentType = "Screening")';
$where = ' AND (dc.overlap != 0 OR ifnull(et.name, dcg.experimenttype) = "Screening")';
else if ($this->arg('t') == 'gr')
$where = ' AND dc.axisrange = 0';
else if ($this->arg('t') == 'fc')
$where = ' AND dc.overlap = 0 AND dc.axisrange > 0 AND dc.numberOfImages > 1 AND dcg.experimentType != "Screening"';
$where = ' AND dc.overlap = 0 AND dc.axisrange > 0 AND dc.numberOfImages > 1 AND ifnull(et.name, dcg.experimenttype) != "Screening"';
} else if ($this->arg('t') == 'edge') {
$where2 = '';
} else if ($this->arg('t') == 'mca') {
Expand Down Expand Up @@ -156,7 +156,7 @@ function _data_collections($single = null)
// Single crystal or explicitly non-single-crystal fields
$where = ($this->arg('t') == "nscrystal") ? ' AND NOT ' : ' AND ';
// This IS NOT NULL is not redundant; this condition always evalutes to TRUE with AND NOT without it
$where .= '(dcg.experimentType IS NOT NULL AND dcg.experimentType in ("OSC", "Diamond Anvil High Pressure"))';
$where .= '(ifnull(et.name, dcg.experimenttype) IS NOT NULL AND ifnull(et.name, dcg.experimenttype) in ("OSC", "Diamond Anvil High Pressure"))';
}
}

Expand Down Expand Up @@ -396,7 +396,7 @@ function _data_collections($single = null)
dc.kappastart as kappa,
dc.phistart as phi,
dc.startimagenumber as si,
dcg.experimenttype as dct,
ifnull(et.name, dcg.experimenttype) as dct,
dc.datacollectiongroupid as dcg,
dc.runstatus,
dc.beamsizeatsamplex as bsx,
Expand Down Expand Up @@ -476,7 +476,7 @@ function _data_collections($single = null)
dc.kappastart,
dc.phistart,
dc.startimagenumber,
dc.experimenttype,
ifnull(et.name, dcg.experimenttype),
dc.datacollectiongroupid,
dc.runstatus,
dc.beamsizeatsamplex,
Expand Down Expand Up @@ -530,7 +530,7 @@ function _data_collections($single = null)
min(dc.kappastart) as kappa,
min(dc.phistart) as phi,
min(dc.startimagenumber) as si,
min(dcg.experimenttype) as dct,
min(ifnull(et.name, dcg.experimenttype)) as dct,
dc.datacollectiongroupid as dcg,
min(dc.runstatus) as runstatus,
min(dc.beamsizeatsamplex) as bsx,
Expand Down Expand Up @@ -614,6 +614,7 @@ function _data_collections($single = null)
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
$sample_joins[0]
$extj[0]
WHERE $sess[0] $where
Expand Down Expand Up @@ -660,6 +661,7 @@ function _data_collections($single = null)
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
$sample_joins[0]
LEFT OUTER JOIN datacollectioncomment dcc ON dc.datacollectionid = dcc.datacollectionid
LEFT OUTER JOIN datacollectionfileattachment dca ON dc.datacollectionid = dca.datacollectionid
Expand Down
5 changes: 1 addition & 4 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,6 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
count(distinct IF(dc.overlap = 0 AND dc.axisrange > 0,dc.datacollectionid,NULL)) as dc,
count(distinct so.screeningid) as ai,
count(distinct app.autoprocprogramid) as ap,
count(distinct IF(dcg.experimenttype LIKE 'XRF map', dc.datacollectionid, NULL)) as xm,
count(distinct IF(dcg.experimenttype LIKE 'XRF spectrum', dc.datacollectionid, NULL)) as xs,
count(distinct IF(dcg.experimenttype LIKE 'Energy scan', dc.datacollectionid, NULL)) as es,
round(min(st.rankingresolution),2) as scresolution,
max(ssw.completeness) as sccompleteness,
round(min(apss.resolutionlimithigh),2) as dcresolution,
Expand Down Expand Up @@ -1181,7 +1178,7 @@ function _samples()
$order = $cols[$this->arg('sort_by')] . ' ' . $dir;
}

$rows = $this->db->paginate("SELECT distinct b.blsampleid, b.crystalid, b.screencomponentgroupid, ssp.blsampleid as parentsampleid, ssp.name as parentsample, b.blsubsampleid, count(distinct si.blsampleimageid) as inspections, CONCAT(p.proposalcode,p.proposalnumber) as prop, b.code, b.location, pr.acronym, pr.proteinid, cr.spacegroup,b.comments,b.name,s.shippingname as shipment,s.shippingid,d.dewarid,d.code as dewar, c.code as container, c.containerid, c.samplechangerlocation as sclocation, count(distinct IF(dc.overlap != 0,dc.datacollectionid,NULL)) as sc, count(distinct IF(dc.overlap = 0 AND dc.axisrange = 0,dc.datacollectionid,NULL)) as gr, count(distinct IF(dc.overlap = 0 AND dc.axisrange > 0,dc.datacollectionid,NULL)) as dc, count(distinct IF(dcg.experimenttype LIKE 'XRF map', dc.datacollectionid, NULL)) as xm, count(distinct IF(dcg.experimenttype LIKE 'XRF spectrum', dc.datacollectionid, NULL)) as xs, count(distinct IF(dcg.experimenttype LIKE 'Energy scan', dc.datacollectionid, NULL)) as es, count(distinct so.screeningid) as ai, count(distinct app.autoprocprogramid) as ap, count(distinct r.robotactionid) as r, round(min(st.rankingresolution),2) as scresolution, max(ssw.completeness) as sccompleteness, round(min(apss.resolutionlimithigh),2) as dcresolution, round(max(apss.completeness),1) as dccompleteness, dp.anomalousscatterer, dp.requiredresolution, cr.cell_a, cr.cell_b, cr.cell_c, cr.cell_alpha, cr.cell_beta, cr.cell_gamma, b.packingfraction, b.dimension1, b.dimension2, b.dimension3, b.shape, cr.color, cr.theoreticaldensity, cr.name as crystal, pr.name as protein, b.looptype, dp.centringmethod, dp.experimentkind, cq.containerqueueid, TO_CHAR(cq.createdtimestamp, 'DD-MM-YYYY HH24:MI') as queuedtimestamp
$rows = $this->db->paginate("SELECT distinct b.blsampleid, b.crystalid, b.screencomponentgroupid, ssp.blsampleid as parentsampleid, ssp.name as parentsample, b.blsubsampleid, count(distinct si.blsampleimageid) as inspections, CONCAT(p.proposalcode,p.proposalnumber) as prop, b.code, b.location, pr.acronym, pr.proteinid, cr.spacegroup,b.comments,b.name,s.shippingname as shipment,s.shippingid,d.dewarid,d.code as dewar, c.code as container, c.containerid, c.samplechangerlocation as sclocation, count(distinct IF(dc.overlap != 0,dc.datacollectionid,NULL)) as sc, count(distinct IF(dc.overlap = 0 AND dc.axisrange = 0,dc.datacollectionid,NULL)) as gr, count(distinct IF(dc.overlap = 0 AND dc.axisrange > 0,dc.datacollectionid,NULL)) as dc, count(distinct so.screeningid) as ai, count(distinct app.autoprocprogramid) as ap, count(distinct r.robotactionid) as r, round(min(st.rankingresolution),2) as scresolution, max(ssw.completeness) as sccompleteness, round(min(apss.resolutionlimithigh),2) as dcresolution, round(max(apss.completeness),1) as dccompleteness, dp.anomalousscatterer, dp.requiredresolution, cr.cell_a, cr.cell_b, cr.cell_c, cr.cell_alpha, cr.cell_beta, cr.cell_gamma, b.packingfraction, b.dimension1, b.dimension2, b.dimension3, b.shape, cr.color, cr.theoreticaldensity, cr.name as crystal, pr.name as protein, b.looptype, dp.centringmethod, dp.experimentkind, cq.containerqueueid, TO_CHAR(cq.createdtimestamp, 'DD-MM-YYYY HH24:MI') as queuedtimestamp
, $cseq $sseq string_agg(cpr.name) as componentnames, string_agg(cpr.density) as componentdensities
,string_agg(cpr.proteinid) as componentids, string_agg(cpr.acronym) as componentacronyms, string_agg(cpr.global) as componentglobals, string_agg(chc.abundance) as componentamounts, string_agg(ct.symbol) as componenttypesymbols, b.volume, pct.symbol,ROUND(cr.abundance,3) as abundance, TO_CHAR(b.recordtimestamp, 'DD-MM-YYYY') as recordtimestamp, dp.radiationsensitivity, dp.energy, dp.userpath, dp.strategyoption, dp.minimalresolution as minimumresolution
,count(distinct dc.dataCollectionId) as dcc
Expand Down
8 changes: 5 additions & 3 deletions api/src/Page/Vstat.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,22 @@ function _error_log()
{
$info = $this->_check_visit();

$dc_tot = $this->db->pq("SELECT dcg.experimenttype, count(dc.datacollectionid) as total
$dc_tot = $this->db->pq("SELECT ifnull(et.name, dcg.experimenttype) as experimenttype, count(dc.datacollectionid) as total
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dc.datacollectiongroupid = dcg.datacollectiongroupid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
WHERE dcg.sessionid=:1
GROUP BY dcg.experimenttype", array($info['SID']));
GROUP BY ifnull(et.name, dcg.experimenttype)", array($info['SID']));

$totals = array();
foreach ($dc_tot as $tot) {
$totals[$tot['EXPERIMENTTYPE']] = intval($tot["TOTAL"]);
}

$dcs = $this->db->pq("SELECT dc.datacollectionid, dcg.experimenttype, dc.starttime, dc.endtime, dc.filetemplate, dc.imagedirectory, dc.runstatus, dca.filefullpath as logfile
$dcs = $this->db->pq("SELECT dc.datacollectionid, ifnull(et.name, dcg.experimenttype) as experimenttype, dc.starttime, dc.endtime, dc.filetemplate, dc.imagedirectory, dc.runstatus, dca.filefullpath as logfile
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dc.datacollectiongroupid = dcg.datacollectiongroupid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
LEFT OUTER JOIN blsample sam ON dc.blsampleid = sam.blsampleid
LEFT OUTER JOIN datacollectionfileattachment dca ON dca.datacollectionid = dc.datacollectionid AND dca.filetype = 'log'
WHERE dcg.sessionid=:1 AND dc.runstatus NOT LIKE '%success%'", array($info['SID']));
Expand Down

0 comments on commit 78a1bc4

Please sign in to comment.