Skip to content

Commit 90d96d1

Browse files
ndg63276Mark Williams
andauthored
Merge pre-release/2025-R3.2 into master (#949)
* LIMS-1758: Fix slowness with plates with lots of subsamples (#941) * LIMS-1758: Fix slowness with plates with lots of samples * LIMS-1758: Remove unnecessary change * LIMS-1758: Remove unnecessary whitespace * LIMS-1758: Do large updates in chunks * LIMS-1758: Use native JS --------- Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> * LIMS-1715: Clear sessionId from containers if a dewar transfer is requested (#939) * LIMS-1715: Clear sessionId from containers if a dewar transfer is requested * LIMS-1715: Clear sessionId from containers if a dewar transfer is requested --------- Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> * LIMS-1714: Populate Dewar.dewarRegistryId (#936) Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> * LIMS-1701: Make Xray Centring results an openable table (#935) Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> * LIMS-1642: Fix search when clicking x on search bars (#909) Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> * LIMS-1639: List most common screens at the top of the list (#928) Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> * LIMS-1777: Fix download of autoprocessing attachments on sm beamlines (#947) Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> --------- Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent aec73d2 commit 90d96d1

File tree

15 files changed

+193
-60
lines changed

15 files changed

+193
-60
lines changed

api/src/Page/DC.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,20 +1508,25 @@ function _grid_xrc()
15081508
$info = $this->db->pq("SELECT dc.datacollectiongroupid, dc.datacollectionid,
15091509
xrc.xraycentringtype as method, xrcr.xraycentringresultid,
15101510
xrcr.centreofmassx as x, xrcr.centreofmassy as y, xrcr.centreofmassz as z,
1511-
xrcr.totalcount
1511+
xrcr.totalcount,
1512+
xrcr.boundingboxmaxx-xrcr.boundingboxminx as sizex,
1513+
xrcr.boundingboxmaxy-xrcr.boundingboxminy as sizey,
1514+
xrcr.boundingboxmaxz-xrcr.boundingboxminz as sizez,
1515+
s.blsampleid, s.name
15121516
FROM datacollection dc
15131517
INNER JOIN xraycentring xrc ON xrc.datacollectiongroupid = dc.datacollectiongroupid
15141518
INNER JOIN xraycentringresult xrcr ON xrcr.xraycentringid = xrc.xraycentringid
1515-
WHERE dc.datacollectionid = :1 ", array($this->arg('id')));
1519+
LEFT JOIN blsample s ON xrcr.blsampleid = s.blsampleid
1520+
WHERE dc.datacollectionid = :1
1521+
ORDER BY xrcr.totalcount desc", array($this->arg('id')));
15161522

15171523
if (!sizeof($info))
15181524
$this->_output(array('total' => 0, 'data' => array()));
15191525
else {
15201526
foreach ($info as &$i) {
15211527
foreach ($i as $k => &$v) {
1522-
if ($k == 'METHOD')
1523-
continue;
1524-
$v = round(floatval($v), 2);
1528+
if ($k == 'X' || $k == 'Y' || $k == 'Z')
1529+
$v = number_format($v, 1);
15251530
}
15261531
}
15271532
$this->_output(array('total' => sizeof($info), 'data' => $info));

api/src/Page/Imaging.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,11 +866,12 @@ function _get_screens()
866866
array_push($args, $this->arg('scid'));
867867
}
868868

869-
$screens = $this->db->pq("SELECT ct.name as containertypeid, IFNULL(ct.capacity, 96) as capacity, CONCAT(p.proposalcode, p.proposalnumber) as prop, s.global, s.name, s.screenid, s.proposalid, count(distinct sg.screencomponentgroupid) as groups, count(distinct sc.screencomponentid) as components
869+
$screens = $this->db->pq("SELECT ct.name as containertypeid, IFNULL(ct.capacity, 96) as capacity, CONCAT(p.proposalcode, p.proposalnumber) as prop, s.global, s.name, s.screenid, s.proposalid, count(distinct sg.screencomponentgroupid) as groups, count(distinct sc.screencomponentid) as components, COUNT(DISTINCT c.containerid) AS cnt
870870
FROM screen s
871871
LEFT OUTER JOIN screencomponentgroup sg ON sg.screenid = s.screenid
872872
LEFT OUTER JOIN screencomponent sc ON sc.screencomponentgroupid = sg.screencomponentgroupid
873873
LEFT OUTER JOIN containertype ct ON ct.containertypeid = s.containertypeid
874+
LEFT OUTER JOIN container c ON c.screenId = s.screenid
874875
INNER JOIN proposal p ON p.proposalid = s.proposalid
875876
WHERE $where
876877
GROUP BY CONCAT(p.proposalcode, p.proposalnumber), s.global, s.name, s.screenid, s.proposalid", $args);

api/src/Page/Shipment.php

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Shipment extends Page
3838

3939
// Dewar Fields
4040
'CODE' => '([\w\-])+',
41-
'FACILITYCODE' => '([\w\-])+',
41+
'FACILITYCODE' => '([\w\-])*',
4242
'NEWFACILITYCODE' => '([\w\-])+',
4343
'TRACKINGNUMBERTOSYNCHROTRON' => '\w*',
4444
'TRACKINGNUMBERFROMSYNCHROTRON' => '\w*',
@@ -957,6 +957,11 @@ function _transfer_dewar()
957957

958958
// Update dewar status to transfer-requested to keep consistent with history
959959
$this->db->pq("UPDATE dewar set dewarstatus='transfer-requested' WHERE dewarid=:1", array($this->arg('DEWARID')));
960+
// Remove sessionId from containers and unqueue any pucks, so it doesnt look like a finished UDC dewar
961+
$this->db->pq("UPDATE container set sessionid=NULL WHERE dewarid=:1", array($this->arg('DEWARID')));
962+
$this->db->pq("DELETE cq from containerqueue cq
963+
INNER JOIN container c ON c.containerid = cq.containerid
964+
WHERE dewarid=:1", array($this->arg('DEWARID')));
960965

961966
if ($this->has_arg('NEXTVISIT')) {
962967
$sessions = $this->db->pq(
@@ -1729,7 +1734,7 @@ function _get_dewars()
17291734
CONCAT(p.proposalcode, p.proposalnumber, '-', se2.visit_number) as udcfirstexperiment,
17301735
r.labcontactid, se.beamlineoperator as localcontact, se.beamlinename,
17311736
TO_CHAR(se.startdate, 'HH24:MI DD-MM-YYYY') as firstexperimentst, d.firstexperimentid,
1732-
s.shippingid, s.shippingname, d.facilitycode, count(c.containerid) as ccount,
1737+
s.shippingid, s.shippingname, IFNULL(r.facilitycode, d.facilitycode) as facilitycode, count(c.containerid) as ccount,
17331738
(case when se.visit_number > 0 then (CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number)) else '' end) as exp,
17341739
d.code, d.barcode, d.storagelocation, d.dewarstatus, d.dewarid,
17351740
d.trackingnumbertosynchrotron, d.trackingnumberfromsynchrotron, d.externalShippingIdFromSynchrotron,
@@ -1741,11 +1746,11 @@ function _get_dewars()
17411746
INNER JOIN proposal p ON p.proposalid = s.proposalid
17421747
LEFT OUTER JOIN blsession se ON d.firstexperimentid = se.sessionid
17431748
LEFT OUTER JOIN blsession se2 ON c.sessionid = se2.sessionid
1744-
LEFT OUTER JOIN dewarregistry r ON r.facilitycode = d.facilitycode
1749+
LEFT OUTER JOIN dewarregistry r ON r.dewarregistryid = d.dewarregistryid
17451750
LEFT OUTER JOIN labcontact lc ON s.sendinglabcontactid = lc.labcontactid
17461751
LEFT OUTER JOIN person pe ON lc.personid = pe.personid
17471752
WHERE $where
1748-
GROUP BY CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number), r.labcontactid, se.beamlineoperator, TO_CHAR(se.startdate, 'HH24:MI DD-MM-YYYY'), (case when se.visit_number > 0 then (CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number)) else '' end),s.shippingid, s.shippingname, d.code, d.barcode, d.storagelocation, d.dewarstatus, d.dewarid, d.trackingnumbertosynchrotron, d.trackingnumberfromsynchrotron, d.facilitycode, d.firstexperimentid
1753+
GROUP BY CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number), r.labcontactid, se.beamlineoperator, TO_CHAR(se.startdate, 'HH24:MI DD-MM-YYYY'), (case when se.visit_number > 0 then (CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number)) else '' end),s.shippingid, s.shippingname, d.code, d.barcode, d.storagelocation, d.dewarstatus, d.dewarid, d.trackingnumbertosynchrotron, d.trackingnumberfromsynchrotron, facilitycode, d.firstexperimentid
17491754
ORDER BY $order", $args);
17501755

17511756
if ($this->has_arg('did')) {
@@ -1779,6 +1784,7 @@ function _add_dewar()
17791784
$to = $this->has_arg('TRACKINGNUMBERTOSYNCHROTRON') ? $this->arg('TRACKINGNUMBERTOSYNCHROTRON') : '';
17801785
$from = $this->has_arg('TRACKINGNUMBERFROMSYNCHROTRON') ? $this->arg('TRACKINGNUMBERFROMSYNCHROTRON') : '';
17811786
$fc = $this->has_arg('FACILITYCODE') ? $this->arg('FACILITYCODE') : '';
1787+
$drid = $this->_get_dewarregistryid($fc);
17821788
$wg = $this->has_arg('WEIGHT') ? $this->arg('WEIGHT') : $dewar_weight;
17831789
$exp = null;
17841790
$source = $this->has_arg('SOURCE') ? $this->arg('SOURCE') : null;
@@ -1789,9 +1795,9 @@ function _add_dewar()
17891795
}
17901796

17911797
$this->db->pq(
1792-
"INSERT INTO dewar (dewarid,code,trackingnumbertosynchrotron,trackingnumberfromsynchrotron,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight,source)
1793-
VALUES (s_dewar.nextval,:1,:2,:3,:4,CURRENT_TIMESTAMP,'opened',:5,:6,:7,IFNULL(:8,CURRENT_USER)) RETURNING dewarid INTO :id",
1794-
array($this->arg('CODE'), $to, $from, $this->arg('SHIPPINGID'), $exp, $fc, $wg, $source)
1798+
"INSERT INTO dewar (dewarid,code,trackingnumbertosynchrotron,trackingnumberfromsynchrotron,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,dewarregistryid,weight,source)
1799+
VALUES (s_dewar.nextval,:1,:2,:3,:4,CURRENT_TIMESTAMP,'opened',:5,:6,:7,:8,IFNULL(:9,CURRENT_USER)) RETURNING dewarid INTO :id",
1800+
array($this->arg('CODE'), $to, $from, $this->arg('SHIPPINGID'), $exp, $fc, $drid, $wg, $source)
17951801
);
17961802

17971803
$id = $this->db->id();
@@ -1937,6 +1943,9 @@ function _update_dewar()
19371943
} else {
19381944
$this->_output(1);
19391945
}
1946+
} else if ($f === 'FACILITYCODE') {
1947+
$drid = $this->_get_dewarregistryid($this->arg($f));
1948+
$this->db->pq("UPDATE dewar SET $f=:1, dewarregistryid=:2 WHERE dewarid=:3", array($this->arg($f), $drid, $this->arg('did')));
19401949
} else {
19411950
$this->db->pq("UPDATE dewar SET $f=:1 WHERE dewarid=:2", array($this->arg($f), $this->arg('did')));
19421951
$this->_output(array($f => $this->arg($f)));
@@ -3141,11 +3150,12 @@ function _add_shipment()
31413150
for ($i = 0; $i < $this->arg('DEWARS'); $i++) {
31423151
$fc = $i < sizeof($this->arg('FCODES')) ? $fcs[$i] : '';
31433152
$n = $fc ? $fc : ('Dewar' . ($i + 1));
3153+
$drid = $this->_get_dewarregistryid($fc);
31443154

31453155
$this->db->pq(
3146-
"INSERT INTO dewar (dewarid,code,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight,source)
3147-
VALUES (s_dewar.nextval,:1,:2,CURRENT_TIMESTAMP,'opened',:3,:4,:5,IFNULL(:6,CURRENT_USER)) RETURNING dewarid INTO :id",
3148-
array($n, $sid, $exp, $fc, $dewar_weight, $source)
3156+
"INSERT INTO dewar (dewarid,code,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,dewarregistryid,weight,source)
3157+
VALUES (s_dewar.nextval,:1,:2,CURRENT_TIMESTAMP,'opened',:3,:4,:5,:6,IFNULL(:7,CURRENT_USER)) RETURNING dewarid INTO :id",
3158+
array($n, $sid, $exp, $fc, $drid, $dewar_weight, $source)
31493159
);
31503160

31513161
$id = $this->db->id();
@@ -3165,6 +3175,17 @@ function _add_shipment()
31653175
$this->_output(array('SHIPPINGID' => $sid));
31663176
}
31673177

3178+
function _get_dewarregistryid($fc)
3179+
{
3180+
$drid = null;
3181+
if ($fc) {
3182+
$dr = $this->db->pq("SELECT dewarregistryid FROM dewarregistry where facilitycode=:1", array($fc));
3183+
if (sizeof($dr))
3184+
$drid = $dr[0]['DEWARREGISTRYID'];
3185+
}
3186+
return $drid;
3187+
}
3188+
31683189
function _get_default_dewar()
31693190
{
31703191
if ($this->has_arg('visit')) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
define(['backbone'], function(Backbone) {
2+
3+
return Backbone.Collection.extend({
4+
5+
url: function() { return '/dc/grid/xrc/' + this.id },
6+
7+
initialize: function(options) {
8+
this.id = options.id
9+
},
10+
11+
parse: function(r) {
12+
return r.data
13+
},
14+
})
15+
16+
})

client/src/js/modules/dc/models/gridxrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

client/src/js/modules/dc/views/autoprocattachments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ define(['marionette',
154154
var iCatProposalRootURL = this.getICatProposalRootUrl(proposalID);
155155

156156
this.isIndustry = this.hasIndustryPrefix(proposalID); // ! FIXME: Naive check.
157-
this.isPurgedSession = options.dcPurgedProcessedData !== "0";
157+
this.isPurgedSession = (options && options.dcPurgedProcessedData) ? (options.dcPurgedProcessedData !== "0") : false;
158158

159159
var columns = [
160160
{ name: 'FILENAME', label: 'File', cell: 'string', editable: false },

client/src/js/modules/dc/views/grid.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ define(['marionette',
1010
'modules/dc/views/dccomments',
1111
'modules/dc/views/attachments',
1212
'modules/dc/views/apstatusitem',
13-
'modules/dc/models/gridxrc',
13+
'modules/dc/views/gridxrc',
1414
'templates/dc/grid.html', 'backbone-validation'],
1515
function(Marionette, DCBase, TabView, AddToProjectView, Editable, Backbone, ImageViewer, GridPlot,
1616
DialogView, DCCommentsView, AttachmentsView, APStatusItem, GridXRC,
@@ -22,6 +22,7 @@ define(['marionette',
2222
apStatusItem: APStatusItem,
2323

2424
events: {
25+
'click .holder h1.xrc': 'loadXRC',
2526
'click @ui.zoom': 'toggleZoom'
2627
},
2728

@@ -136,24 +137,16 @@ define(['marionette',
136137
}
137138

138139
if (state >= 2) {
139-
this.xrc = new GridXRC({ id: this.model.get('ID') })
140-
this.xrc.fetch({
141-
success: this.showXRC.bind(this)
142-
})
140+
this.xrc = new GridXRC({ id: this.model.get('ID'), el: this.$el.find('div.xrc') })
143141
}
144142
}
145143
},
146144

147-
showXRC: function() {
148-
var xrcs = this.xrc.get('data')
149-
var t = ''
150-
for (var i = 0; i < xrcs.length; i++) {
151-
t += ' - Crystal '+(i+1)+': X Pos '+xrcs[i]['X']+' Y Pos '+xrcs[i]['Y']+' Z Pos '+xrcs[i]['Z']+' Strength '+xrcs[i]['TOTALCOUNT']
152-
}
153-
if (xrcs.length > 0) {
154-
this.ui.holder.prepend('Method: '+xrcs[0]['METHOD']+t)
145+
loadXRC: function(e) {
146+
if (!this.xrc) {
147+
this.xrc = new GridXRC({ id: this.model.get('ID'), el: this.$el.find('div.xrc') })
155148
} else {
156-
this.ui.holder.prepend('Found no diffraction')
149+
this.xrc.$el.slideToggle()
157150
}
158151
},
159152

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
define(['marionette',
2+
'modules/dc/collections/gridxrc',
3+
'views/table',
4+
'utils/table'], function(Marionette, GridXRC, TableView, table) {
5+
6+
var linkIfSample = function(data) {
7+
if (data.BLSAMPLEID) {
8+
return '<a href="/samples/sid/'+data.BLSAMPLEID+'"><i class="fa fa-search"></i> '+data.NAME+'</a>'
9+
} else {
10+
return ''
11+
}
12+
}
13+
14+
return Marionette.LayoutView.extend({
15+
template: _.template('<div class="summary"></div>'),
16+
regions: {
17+
summary: '.summary',
18+
},
19+
20+
initialize: function(options) {
21+
this.collection = new GridXRC({ id: options.id })
22+
this.collection.fetch().done(this.render.bind(this))
23+
},
24+
25+
onRender: function() {
26+
this.summary.show(new TableView({
27+
className: 'ui-tabs-panel',
28+
noTableHolder: true,
29+
collection: this.collection,
30+
columns: [
31+
{ label: 'Sample', cell: table.TemplateCell, template: d=>linkIfSample(d), editable: false },
32+
{ name: 'METHOD', label: 'Method', cell: 'string', editable: false },
33+
{ name: 'TOTALCOUNT', label: 'Strength', cell: 'string', editable: false },
34+
{ name: 'X', label: 'Pos X (Boxes)', cell: 'string', editable: false },
35+
{ name: 'Y', label: 'Pos Y (Boxes)', cell: 'string', editable: false },
36+
{ name: 'Z', label: 'Pos Z (Boxes)', cell: 'string', editable: false },
37+
{ name: 'SIZEX', label: 'Size X (Boxes)', cell: 'string', editable: false },
38+
{ name: 'SIZEY', label: 'Size Y (Boxes)', cell: 'string', editable: false },
39+
{ name: 'SIZEZ', label: 'Size Z (Boxes)', cell: 'string', editable: false },
40+
],
41+
pages: false,
42+
backgrid: {
43+
emptyText: 'No xray centring results available for this data collection',
44+
},
45+
}))
46+
},
47+
})
48+
49+
})

client/src/js/modules/imaging/views/imageviewer.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,11 @@ define(['marionette',
604604
},
605605

606606
calcZoom: function() {
607-
var min = this.ui.canvas.width() < this.ui.canvas.height() ? this.ui.canvas.width()/this.width : this.ui.canvas.height()/this.height
608-
this.ui.zoom.slider('option', 'min', 100*min)
609-
this.onZoomChange()
607+
if (this.ui.zoom.hasClass('ui-slider')) {
608+
var min = this.ui.canvas.width() < this.ui.canvas.height() ? this.ui.canvas.width()/this.width : this.ui.canvas.height()/this.height
609+
this.ui.zoom.slider('option', 'min', 100*min)
610+
this.onZoomChange()
611+
}
610612
},
611613

612614
clampOffsets: function() {

0 commit comments

Comments
 (0)