Skip to content

Commit

Permalink
LIMS-1458: Do sorting on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Williams committed Oct 7, 2024
1 parent 0671e1a commit 74b24c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
8 changes: 4 additions & 4 deletions api/src/Page/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ function _beamlines()
$pdb = $this->db->pq("SELECT TO_CHAR(p.pdbdate, 'YYYY') as year, $replace as bl, count(p.pdbentryid) as count
FROM pdbentry p
WHERE p.pdbdate > TO_DATE('2010-05', 'YYYY-MM')
GROUP BY $replace, TO_CHAR(p.pdbdate, 'YYYY')
ORDER BY TO_CHAR(p.pdbdate, 'YYYY')");
GROUP BY bl, year
ORDER BY year, bl");

$isp = $this->db->pq("SELECT TO_CHAR(p.pdbdate, 'YYYY') as year, CASE WHEN p.autoprocprogramid > 0 THEN UPPER(s.beamlinename) ELSE $replace END as bl, count(p.pdbentryid) as count
FROM pdbentry p
Expand All @@ -284,8 +284,8 @@ function _beamlines()
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE p.pdbdate > TO_DATE('2010-05', 'YYYY-MM')
GROUP BY CASE WHEN p.autoprocprogramid > 0 THEN UPPER(s.beamlinename) ELSE $replace END, TO_CHAR(p.pdbdate, 'YYYY')
ORDER BY TO_CHAR(p.pdbdate, 'YYYY')");
GROUP BY bl, year
ORDER BY year, bl");

foreach ($pdb as $i => &$s) {
$s['COUNT'] = intval(($s['COUNT']));
Expand Down
25 changes: 12 additions & 13 deletions client/src/js/modules/cell/views/beamlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ define(['marionette', 'utils',
template: false,
modelEvents: { 'change': 'render' },

ascsort: function(a,b) {
if (a[0] == b[0]) return 0
else return (a[0] < b[0]) ? -1 : 1
},

onRender: function() {
if (this.model.get('data')) {
var did = this.getOption('second') ? 1 : 0
Expand All @@ -35,24 +30,28 @@ define(['marionette', 'utils',
})

var bl = []
var data = {}
_.each(bls, function(i, b) {
data[b] = {}
bl.push(b)
ticks.push([bl.length-1, b])
_.each(years, function(x, y) {
data[b][y] = 0
})
})

_.each(this.model.get('data')[did], function(v, i) {
var y = yrs.indexOf(v.YEAR)
var b = bl.indexOf(v.BL)
//console.log('d', y, b)
d[y].data.push([b, v.COUNT])
data[v.BL][v.YEAR] = v.COUNT
})

_.each(d, function(d,i) {
d.data.sort(this.ascsort)
_.each(data, function(el, beamline) {
_.each(el, function(count, year) {
var y = yrs.indexOf(year)
var b = bl.indexOf(beamline)
d[y].data.push([b, count])
})
})

console.log(d)

var options = {
series: {
bars: {
Expand Down

0 comments on commit 74b24c4

Please sign in to comment.