Skip to content

Commit

Permalink
Merge pull request #531 from DiamondLightSource/prerelease
Browse files Browse the repository at this point in the history
Bad merge left and else rows in (#530)
  • Loading branch information
John-Holt-Tessella authored Apr 21, 2023
2 parents 09ad866 + 1ecd923 commit ab6a5bc
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions api/src/Page/Exp.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,38 +164,34 @@ function _detectors()
array_push($args, $this->arg('BEAMLINENAME'));
}

$tot = $this->db->pq("SELECT count(d.detectorid) as tot
FROM detector d
LEFT OUTER JOIN beamlinesetup bls ON bls.detectorid = d.detectorid
WHERE $where", $args);
$tot = intval($tot[0]['TOT']);
$tot = $this->db->pq("SELECT count(d.detectorid) as tot
FROM detector d
LEFT OUTER JOIN beamlinesetup bls ON bls.detectorid = d.detectorid
WHERE $where", $args);
$tot = intval($tot[0]['TOT']);

$this->_get_start_end($args);
$this->_get_start_end($args);

$order = $this->_get_order(
array('DETECTORID' => 'd.detectorid'),
'd.detectorid ASC'
);
$order = $this->_get_order(
array('DETECTORID' => 'd.detectorid'),
'd.detectorid ASC'
);

$rows = $this->db->paginate("SELECT d.detectorid, d.detectortype, d.detectormanufacturer, d.detectorserialnumber, d.sensorthickness, d.detectormodel, d.detectorpixelsizehorizontal, d.detectorpixelsizevertical, d.detectordistancemin, d.detectordistancemax, d.density, d.composition, concat(d.detectormanufacturer,' ',d.detectormodel, ' (',d.detectortype,')') as description, d.detectormaxresolution, d.detectorminresolution, count(distinct dc.datacollectionid) as dcs, count(distinct bls.beamlinesetupid) as blsetups, (SELECT count(distinct dphd.detectorid) FROM DataCollectionPlan_has_Detector dphd WHERE dphd.detectorid = d.detectorid) as dps, GROUP_CONCAT(distinct bls.beamlinename) as beamlines, d.numberofpixelsx, d.numberofpixelsy, d.detectorrollmin, d.detectorrollmax
FROM detector d
LEFT OUTER JOIN datacollection dc ON dc.detectorid = d.detectorid
LEFT OUTER JOIN beamlinesetup bls ON bls.detectorid = d.detectorid
WHERE $where
GROUP BY d.detectorid
ORDER BY $order", $args);
$rows = $this->db->paginate("SELECT d.detectorid, d.detectortype, d.detectormanufacturer, d.detectorserialnumber, d.sensorthickness, d.detectormodel, d.detectorpixelsizehorizontal, d.detectorpixelsizevertical, d.detectordistancemin, d.detectordistancemax, d.density, d.composition, concat(d.detectormanufacturer,' ',d.detectormodel, ' (',d.detectortype,')') as description, d.detectormaxresolution, d.detectorminresolution, count(distinct dc.datacollectionid) as dcs, count(distinct bls.beamlinesetupid) as blsetups, (SELECT count(distinct dphd.detectorid) FROM DataCollectionPlan_has_Detector dphd WHERE dphd.detectorid = d.detectorid) as dps, GROUP_CONCAT(distinct bls.beamlinename) as beamlines, d.numberofpixelsx, d.numberofpixelsy, d.detectorrollmin, d.detectorrollmax
FROM detector d
LEFT OUTER JOIN datacollection dc ON dc.detectorid = d.detectorid
LEFT OUTER JOIN beamlinesetup bls ON bls.detectorid = d.detectorid
WHERE $where
GROUP BY d.detectorid
ORDER BY $order", $args);

if ($this->has_arg('DETECTORID')) {
if (sizeof($rows)) $this->_output($rows[0]);
else $this->_error('No such detector');

} else $this->_output(array(
'total' => $tot,
'data' => $rows,
));
}
else
$this->_output($rows);
if ($this->has_arg('DETECTORID')) {
if (sizeof($rows)) $this->_output($rows[0]);
else $this->_error('No such detector');
} else $this->_output(array(
'total' => $tot,
'data' => $rows,
));
}


Expand Down

0 comments on commit ab6a5bc

Please sign in to comment.