diff --git a/api/src/Page/DC.php b/api/src/Page/DC.php index 945d59a95..658f17a1c 100644 --- a/api/src/Page/DC.php +++ b/api/src/Page/DC.php @@ -1264,7 +1264,16 @@ function _dc_strategies($id) { global $strat_align; - $rows = $this->db->pq("SELECT s.programversion, st.rankingresolution as rankres, ssw.wedgenumber, sssw.subwedgenumber, ssw.chi, ssw.kappa, ssw.phi, dc.datacollectionid as dcid, s.comments, dc.transmission as dctrn, dc.wavelength as lam, dc.imagedirectory imd, dc.imageprefix as imp, dc.comments as dcc, dc.blsampleid as sid, sl.spacegroup as sg, sl.unitcell_a as a, sl.unitcell_b as b, sl.unitcell_c as c, sl.unitcell_alpha as al, sl.unitcell_beta as be, sl.unitcell_gamma as ga, CONCAT(CONCAT(IF(sssw.comments, sssw.comments, IF(ssw.comments, ssw.comments, s.shortcomments)), ' Wedge'), IFNULL(ssw.wedgenumber, '')) as com, sssw.axisstart as st, sssw.exposuretime as time, sssw.transmission as tran, sssw.oscillationrange as oscran, sssw.resolution as res, sssw.numberofimages as nimg, det.numberofpixelsx, det.detectorpixelsizehorizontal, sssw.rotationaxis + $rows = $this->db->pq("SELECT s.programversion, s.comments, + st.rankingresolution as rankres, + ssw.wedgenumber, ssw.chi, ssw.kappa, ssw.phi, ssw.comments as sswcomments, + sssw.subwedgenumber, sssw.axisstart as st, sssw.exposuretime as time, sssw.transmission as tran, + sssw.oscillationrange as oscran, sssw.resolution as res, sssw.numberofimages as nimg, sssw.rotationaxis, + dc.datacollectionid as dcid, dc.transmission as dctrn, dc.wavelength as lam, dc.imagedirectory imd, + dc.imageprefix as imp, dc.comments as dcc, dc.blsampleid as sid, + sl.spacegroup as sg, sl.unitcell_a as a, sl.unitcell_b as b, sl.unitcell_c as c, sl.unitcell_alpha as al, sl.unitcell_beta as be, sl.unitcell_gamma as ga, + det.numberofpixelsx, det.detectorpixelsizehorizontal, + CONCAT(IF(sssw.comments, sssw.comments, IF(ssw.comments, ssw.comments, s.shortcomments)), ' Wedge', IFNULL(ssw.wedgenumber, '')) as com FROM screeningstrategy st INNER JOIN screeningoutput so on st.screeningoutputid = so.screeningoutputid INNER JOIN screening s on so.screeningid = s.screeningid @@ -1292,6 +1301,11 @@ function _dc_strategies($id) } if ($is_align) { + foreach ($r as $k => &$v) { + if (in_array($k, $nf)) { + $v = number_format(floatval($v), 2); + } + } array_push($output[$r['PROGRAMVERSION']]['STRATS'], $r); } else { diff --git a/api/src/Page/Processing.php b/api/src/Page/Processing.php index 5dd43b1b9..4abff179b 100644 --- a/api/src/Page/Processing.php +++ b/api/src/Page/Processing.php @@ -148,22 +148,27 @@ function _screening_status($where, $ids) { INNER JOIN datacollectiongroup dcg on dc.datacollectiongroupid = dcg.datacollectiongroupid INNER JOIN blsession s ON s.sessionid = dcg.sessionid INNER JOIN proposal p ON p.proposalid = s.proposalid - WHERE $where - GROUP BY dc.datacollectionid, sc.programversion", + WHERE sc.autoprocprogramid is null AND $where", $ids ); $statuses = array(); - foreach ($screenings as $screening) { - if (!array_key_exists($screening['DATACOLLECTIONID'], $statuses)) { - $statuses[$screening['DATACOLLECTIONID']][ - 'screening' - ] = array(); + foreach ($screenings as $s) { + if (!array_key_exists($s['DATACOLLECTIONID'], $statuses)) { + $statuses[$s['DATACOLLECTIONID']] = array(); } - - $statuses[$screening['DATACOLLECTIONID']]['screening'][ - $screening['PROGRAMVERSION'] - ] = $this->_map_status($screening["INDEXINGSUCCESS"]); + if (!array_key_exists('screening', $statuses[$s['DATACOLLECTIONID']]) + ) { + $statuses[$s['DATACOLLECTIONID']]['screening'] = array(); + } + if (!array_key_exists($s['PROGRAMVERSION'], $statuses[$s['DATACOLLECTIONID']]['screening']) + ) { + $statuses[$s['DATACOLLECTIONID']]['screening'][$s['PROGRAMVERSION']] = array(); + } + array_push( + $statuses[$s['DATACOLLECTIONID']]['screening'][$s['PROGRAMVERSION']], + $this->_map_status($s['INDEXINGSUCCESS']) + ); } return $statuses; @@ -204,8 +209,9 @@ function _xrc_status($where, $ids) { } function _autoproc_status($where, $ids) { - global $downstream_filter; + global $downstream_filter, $strat_align; $filter = $downstream_filter ? implode("','", $downstream_filter) : ''; + $screening_filter = $strat_align ? implode("','", $strat_align) : ''; $processings = $this->db->union( array( @@ -216,7 +222,9 @@ function _autoproc_status($where, $ids) { INNER JOIN proposal p ON p.proposalid = s.proposalid INNER JOIN autoprocintegration api ON api.datacollectionid = dc.datacollectionid INNER JOIN autoprocprogram app ON api.autoprocprogramid = app.autoprocprogramid - WHERE $where AND app.processingprograms NOT IN ('$filter')", + WHERE $where + AND app.processingprograms NOT IN ('$filter') + AND app.processingprograms NOT IN ('$screening_filter')", "SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'downstream' as type FROM datacollection dc INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid @@ -225,8 +233,22 @@ function _autoproc_status($where, $ids) { INNER JOIN processingjob pj ON pj.datacollectionid = dc.datacollectionid INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid - WHERE $where AND api.autoprocintegrationid IS NULL - AND app.processingprograms NOT IN ('$filter')", + WHERE $where + AND api.autoprocintegrationid IS NULL + AND app.processingprograms NOT IN ('$filter') + AND app.processingprograms NOT IN ('$screening_filter')", + "SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'screening' as type + FROM datacollection dc + INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid + INNER JOIN blsession s ON s.sessionid = dcg.sessionid + INNER JOIN proposal p ON p.proposalid = s.proposalid + INNER JOIN processingjob pj ON pj.datacollectionid = dc.datacollectionid + INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid + LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid + WHERE $where + AND api.autoprocintegrationid IS NULL + AND app.processingprograms NOT IN ('$filter') + AND app.processingprograms IN ('$screening_filter')", ), $ids ); @@ -280,6 +302,30 @@ function _get_ids() { return array($where, $ids); } + function merge_deep_arrays($a, $b) { + foreach ($b as $key => $value) { + if (isset($a[$key])) { + if (is_array($a[$key]) && is_array($value)) { + // Determine if arrays are associative or numeric + if (array_keys($a[$key]) === range(0, count($a[$key]) - 1) && + array_keys($value) === range(0, count($value) - 1)) { + // Both are numeric arrays - merge them + $a[$key] = array_merge($a[$key], $value); + } else { + // At least one is associative - merge recursively + $a[$key] = $this->merge_deep_arrays($a[$key], $value); + } + } else { + // One is not array, overwrite with $b's value + $a[$key] = $value; + } + } else { + $a[$key] = $value; + } + } + return $a; + } + /** * All screening, auto processing, and downstream statuses */ @@ -308,7 +354,8 @@ function _statuses() { $xrcs = $this->_xrc_status($where, $ids); $autoprocs = $this->_autoproc_status($where, $ids); - $statuses = array_replace_recursive($screenings, $xrcs, $autoprocs); + $combined = $this->merge_deep_arrays($screenings, $autoprocs); + $statuses = array_replace_recursive($xrcs, $combined); $out = array(); foreach ($ids as $id) { @@ -667,8 +714,9 @@ function _ap_message() { } function _get_downstreams($dcid = null, $aid = null) { - global $downstream_filter; + global $downstream_filter, $strat_align; $filter = $downstream_filter ? implode("','", $downstream_filter) : ''; + $screening_filter = $strat_align ? implode("','", $strat_align) : ''; $where = ''; $args = array($this->proposalid); @@ -700,6 +748,7 @@ function _get_downstreams($dcid = null, $aid = null) { INNER JOIN proposal p ON p.proposalid = s.proposalid WHERE api.autoprocintegrationid IS NULL AND p.proposalid=:1 $where AND app.processingprograms NOT IN ('$filter') + AND app.processingprograms NOT IN ('$screening_filter') GROUP BY app.autoprocprogramid", $args ); diff --git a/client/src/js/modules/dc/views/apstatusitem.js b/client/src/js/modules/dc/views/apstatusitem.js index d479e1df5..e65ce5358 100644 --- a/client/src/js/modules/dc/views/apstatusitem.js +++ b/client/src/js/modules/dc/views/apstatusitem.js @@ -52,9 +52,16 @@ define(['marionette', 'jquery'], function(Marionette, $) { if (this.getOption('showStrategies')) { this.ui.strat.empty() + var allStrategies = [] _.each(res['screening'], function(sc, n) { - this.ui.strat.append(n+': '+val[sc]+' ') + var strats = {} + _.each(sc, function(a) { + if (!(a in strats)) strats[a] = 0 + strats[a]++ + }) + allStrategies.push(n+': '+_.map(strats, function(c, st) { return c > 1 ? ''+c+'x '+val[st] : val[st]}).join(' ')) }, this) + this.ui.strat.append(allStrategies.join('|')) } if (this.getOption('showProcessing')) { diff --git a/client/src/js/modules/dc/views/autoindexing.js b/client/src/js/modules/dc/views/autoindexing.js index 55d1c0513..ea4389c7c 100644 --- a/client/src/js/modules/dc/views/autoindexing.js +++ b/client/src/js/modules/dc/views/autoindexing.js @@ -8,7 +8,7 @@ define(['marionette', modelEvents: { 'change': 'render' }, getTemplate: function(m) { - return (this.model.get('TYPE') == 'XOalign' || this.model.get('TYPE') == 'dials.align_crystal') ? xotemplate : template + return (this.model.get('TYPE') == 'XOalign' || this.model.get('TYPE').includes('dials.align_crystal')) ? xotemplate : template } }) @@ -31,4 +31,4 @@ define(['marionette', }) -}) \ No newline at end of file +}) diff --git a/client/src/js/templates/dc/dc_xoalign.html b/client/src/js/templates/dc/dc_xoalign.html index 36aec8593..11ca53225 100644 --- a/client/src/js/templates/dc/dc_xoalign.html +++ b/client/src/js/templates/dc/dc_xoalign.html @@ -9,15 +9,29 @@