Fix GET building by toid/uprn
This commit is contained in:
parent
f460aaeef6
commit
1b3fe36e05
@ -40,7 +40,13 @@ function queryBuildingsAtPoint(lng, lat) {
|
|||||||
function queryBuildingsByReference(key, id) {
|
function queryBuildingsByReference(key, id) {
|
||||||
if (key === 'toid'){
|
if (key === 'toid'){
|
||||||
return db.manyOrNone(
|
return db.manyOrNone(
|
||||||
"SELECT * FROM buildings WHERE b.ref_toid = $1",
|
`SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
buildings
|
||||||
|
WHERE
|
||||||
|
ref_toid = $1
|
||||||
|
`,
|
||||||
[id]
|
[id]
|
||||||
).catch(function(error){
|
).catch(function(error){
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -49,8 +55,10 @@ function queryBuildingsByReference(key, id) {
|
|||||||
}
|
}
|
||||||
if (key === 'uprn') {
|
if (key === 'uprn') {
|
||||||
return db.manyOrNone(
|
return db.manyOrNone(
|
||||||
`SELECT b.*
|
`SELECT
|
||||||
FROM buildings as b, building_properties as p
|
b.*
|
||||||
|
FROM
|
||||||
|
buildings as b, building_properties as p
|
||||||
WHERE
|
WHERE
|
||||||
b.building_id = p.building_id
|
b.building_id = p.building_id
|
||||||
AND
|
AND
|
||||||
|
@ -177,11 +177,7 @@ server.route('/building/:building_id.json')
|
|||||||
.get(function (req, res) {
|
.get(function (req, res) {
|
||||||
const { building_id } = req.params;
|
const { building_id } = req.params;
|
||||||
getBuildingById(building_id).then(function(result){
|
getBuildingById(building_id).then(function(result){
|
||||||
if (result && result.length) {
|
res.send(result);
|
||||||
res.send(result)
|
|
||||||
} else {
|
|
||||||
res.status(404).send({error:'Not Found'})
|
|
||||||
}
|
|
||||||
}).catch(function(error){
|
}).catch(function(error){
|
||||||
console.error(error);
|
console.error(error);
|
||||||
res.send({error:'Database error'})
|
res.send({error:'Database error'})
|
||||||
|
Loading…
Reference in New Issue
Block a user