Skip to content

Commit 5ad1586

Browse files
ndg63276Mark Williams
andauthored
LIMS-1639: List most common screens at the top of the list (#928)
Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent e136916 commit 5ad1586

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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);

client/src/js/modules/types/mx/shipment/views/container-mixin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ export default {
194194
this.imagingScreensCollection = new ImagingScreens(null, { state: { pageSize: 9999 } })
195195

196196
const result = await this.$store.dispatch('getCollection', this.imagingScreensCollection)
197-
this.imagingScreens = [{ NAME: '-', SCREENID: '' }, ... result.toJSON()]
197+
const originalData = result.toJSON()
198+
const resultCopy = JSON.parse(JSON.stringify(originalData))
199+
const top15 = resultCopy.sort((a, b) => Number(b.CNT) - Number(a.CNT)).slice(0, 15)
200+
this.imagingScreens = [{ NAME: '---', SCREENID: '' }, ...top15, { NAME: '---', SCREENID: '' }, ...originalData]
198201
},
199202
async getImagingScheduleComponentsCollection() {
200203
this.imagingScheduleComponentsCollection = new ImagingScheduleComponents(null, { state: { pageSize: 9999 } })

0 commit comments

Comments
 (0)