Skip to content

Commit c618fee

Browse files
ndg63276Mark Williams
andauthored
LIMS-849: Improve view of DC groups (#1024)
* LIMS-849: Improve view of data collection groups * LIMS-849: Add 'stacking' effect for data collection groups * LIMS-849: Make link to group bold * LIMS-849: Change cursor to spinner while processing results load --------- Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent 067acb5 commit c618fee

File tree

22 files changed

+334
-192
lines changed

22 files changed

+334
-192
lines changed

api/src/Page/DC.php

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,7 @@ function _data_collections($single = null)
458458
dc.c2lens,
459459
dc.objaperture,
460460
dc.magnification,
461-
dose.total as totaldose,
462-
CAST(dc.totalabsorbeddose AS DECIMAL(5, 2)) as totalabsdose,
461+
dc.totalabsorbeddose as totaldose,
463462
d.detectorpixelsizehorizontal,
464463
d.detectorpixelsizevertical,
465464
d.detectormanufacturer,
@@ -539,6 +538,12 @@ function _data_collections($single = null)
539538
array_push($args, $this->arg('dcg'));
540539
}
541540
} else {
541+
$groupby = 'GROUP BY dc.datacollectiongroupid';
542+
$numimgs = 'totals.numimg';
543+
if ($this->has_arg('expandgroups')) {
544+
$groupby = 'GROUP BY dc.datacollectionid';
545+
$numimgs = 'dc.numberofimages as numimg';
546+
}
542547
$fields = "count(distinct dca.datacollectionfileattachmentid) as dcac,
543548
if(dca.fileType='recip',1,0) as recip,
544549
count(distinct dcc.datacollectioncommentid) as dccc,
@@ -569,7 +574,7 @@ function _data_collections($single = null)
569574
min(dc.resolution) as resolution,
570575
min(dc.exposuretime) as exposuretime,
571576
min(dc.axisstart) as axisstart,
572-
min(dc.numberofimages) as numimg,
577+
$numimgs,
573578
TO_CHAR(min(dc.starttime), 'DD-MM-YYYY HH24:MI:SS') as st,
574579
min(dc.transmission) as transmission,
575580
min(dc.axisrange) as axisrange,
@@ -596,12 +601,11 @@ function _data_collections($single = null)
596601
max(dc.c2lens) as c2lens,
597602
max(dc.objaperture) as objaperture,
598603
max(dc.magnification) as magnification,
599-
dose.total as totaldose,
600-
CAST(dc.totalabsorbeddose AS DECIMAL(5, 2)) as totalabsdose,
601-
max(d.detectormanufacturer) as detectormanufacturer,
602-
max(d.detectormodel) as detectormodel,
604+
totals.totaldose as totaldose,
603605
max(d.detectorpixelsizehorizontal) as detectorpixelsizehorizontal,
604606
max(d.detectorpixelsizevertical) as detectorpixelsizevertical,
607+
max(d.detectormanufacturer) as detectormanufacturer,
608+
max(d.detectormodel) as detectormodel,
605609
max(TIMESTAMPDIFF('MINUTE', dc.starttime, CURRENT_TIMESTAMP)) as age,
606610
max(dc.numberofpasses) as numberofpasses,
607611
max(dc.c1aperture) as c1aperture,
@@ -626,11 +630,7 @@ function _data_collections($single = null)
626630
max(ses.archived) as archived,
627631
max(ses.purgedProcessedData) as purgedProcessedData,
628632
IFNULL(max(dc.rotationaxis), 'Omega') as rotationaxis,
629-
dc.detector2theta";
630-
$groupby = "GROUP BY dc.datacollectiongroupid";
631-
if ($this->has_arg('expandgroups')) {
632-
$groupby = "GROUP BY dc.datacollectionid";
633-
}
633+
min(dc.detector2theta) as detector2theta";
634634
}
635635

636636
// We don't want to remove duplicates, since if two counts are equal, one might go uncounted
@@ -687,8 +687,8 @@ function _data_collections($single = null)
687687
FROM datacollection dc
688688
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
689689
INNER JOIN (
690-
select datacollectiongroupid, sum(totalabsorbeddose) as total from datacollection group by datacollectiongroupid) dose
691-
ON dc.datacollectiongroupid = dose.datacollectiongroupid
690+
select datacollectiongroupid, sum(totalabsorbeddose) as totaldose, sum(numberofimages) as numimg from datacollection group by datacollectiongroupid) totals
691+
ON dc.datacollectiongroupid = totals.datacollectiongroupid
692692
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
693693
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
694694
$sample_joins[0]
@@ -782,7 +782,6 @@ function _data_collections($single = null)
782782
0,
783783
0,
784784
0,
785-
0,
786785
ses.beamlinename as bl,
787786
es.blsubsampleid,
788787
'',
@@ -879,7 +878,6 @@ function _data_collections($single = null)
879878
0,
880879
0,
881880
0,
882-
0,
883881
ses.beamlinename as bl,
884882
xrf.blsubsampleid,
885883
'',
@@ -976,7 +974,6 @@ function _data_collections($single = null)
976974
0,
977975
0,
978976
0,
979-
0,
980977
ses.beamlinename as bl,
981978
1 as blsubsampleid,
982979
'',
@@ -1441,45 +1438,40 @@ function _get_ap($com)
14411438
function _image_qi($id)
14421439
{
14431440
session_write_close();
1444-
$iqs = array(array(), array(), array(), array(), array());
1441+
$iqs = array(array(), array(), array(), array());
1442+
$args = array($id);
1443+
$offset = 0;
1444+
$offsets = array($id => 0);
1445+
if ($this->has_arg('dcg') && $this->arg('dcg') == 1) {
1446+
$dcs = $this->db->pq("SELECT datacollectionid, numberofimages
1447+
FROM datacollection dc
1448+
WHERE datacollectiongroupid = (
1449+
SELECT dataCollectionGroupId
1450+
FROM DataCollection
1451+
WHERE dataCollectionId = :1
1452+
)
1453+
ORDER BY datacollectionid ASC", $args);
1454+
$args = array();
1455+
foreach ($dcs as $i => $id) {
1456+
array_push($args, $id['DATACOLLECTIONID']);
1457+
$offsets[$id['DATACOLLECTIONID']] = $offset;
1458+
$offset += $id['NUMBEROFIMAGES'];
1459+
}
1460+
}
14451461

1446-
#$this->db->set_debug(True);
1462+
$dcids = implode(', ', $args);
14471463

1448-
$where = $id;
1449-
$args = array();
1450-
/*
1451-
$dcg = $this->db->pq("SELECT datacollectiongroupid as dcg FROM datacollection WHERE datacollectionid=:1", array($id));
1452-
if (!sizeof($dcg)) $this->error('No such data collection');
1453-
$dcids = $this->db->pq("SELECT datacollectionid as id FROM datacollection WHERE datacollectiongroupid=:1", array($dcg[0]['DCG']));
1454-
$where = array();
1455-
$args = array();
1456-
foreach ($dcids as $i => $id) {
1457-
//array_push($where, ':'.($i+1));
1458-
array_push($where, $id['ID']);
1459-
//array_push($args, $id['ID']);
1460-
}
1461-
$where = implode($where, ', ');
1462-
*/
1463-
1464-
/*$tot = $this->db->pq("SELECT count(im.imagenumber) as tot
1465-
FROM image im
1466-
INNER JOIN imagequalityindicators imq ON imq.imageid = im.imageid AND (im.datacollectionid IN ($where))
1467-
ORDER BY imagenumber", $args);
1468-
$int = intval($tot[0]['TOT'] / 250);
1469-
array_push($args, $int);*/
1470-
1471-
#im.datacollectionid=:1
1472-
$imqs = $this->db->pq("SELECT imq.imagenumber as nim, imq.method2res as res, imq.spottotal as s, imq.totalintegratedsignal, imq.goodbraggcandidates as b, imq.dozor_score as d
1464+
$imqs = $this->db->pq("SELECT imq.datacollectionid, imq.imagenumber, imq.method2res, imq.spottotal, imq.totalintegratedsignal, imq.goodbraggcandidates
14731465
FROM imagequalityindicators imq
1474-
WHERE imq.datacollectionid IN ($where)
1475-
ORDER BY imq.imagenumber", $args);
1466+
WHERE imq.datacollectionid IN ($dcids)
1467+
ORDER BY imq.datacollectionid asc, imq.imagenumber asc", array());
14761468

14771469
foreach ($imqs as $imq) {
1478-
array_push($iqs[0], array(intval($imq['NIM']), $this->_null_or($imq['S'], 'int')));
1479-
array_push($iqs[1], array(intval($imq['NIM']), $this->_null_or($imq['B'], 'int')));
1480-
array_push($iqs[2], array(intval($imq['NIM']), $this->_null_or($imq['RES'], 'float')));
1481-
array_push($iqs[3], array(intval($imq['NIM']), $this->_null_or($imq['TOTALINTEGRATEDSIGNAL'], 'float')));
1482-
array_push($iqs[4], array(intval($imq['NIM']), $this->_null_or($imq['D'], 'float')));
1470+
$globalImageNumber = $imq['IMAGENUMBER'] + $offsets[$imq['DATACOLLECTIONID']];
1471+
array_push($iqs[0], array($globalImageNumber, $this->_null_or($imq['SPOTTOTAL'], 'int')));
1472+
array_push($iqs[1], array($globalImageNumber, $this->_null_or($imq['GOODBRAGGCANDIDATES'], 'int')));
1473+
array_push($iqs[2], array($globalImageNumber, $this->_null_or($imq['METHOD2RES'], 'float')));
1474+
array_push($iqs[3], array($globalImageNumber, $this->_null_or($imq['TOTALINTEGRATEDSIGNAL'], 'float')));
14831475
}
14841476

14851477
$this->_output($iqs);

0 commit comments

Comments
 (0)