Merge pull request #224 from tomalrussell/feature/reduce_log_noise

Feature/reduce log noise
This commit is contained in:
Tom Russell 2019-03-18 20:04:24 +00:00 committed by GitHub
commit 831bde542f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -84,7 +84,7 @@ function getBuildingById(id) {
}
function getBuildingLikeById(building_id, user_id) {
return db.one(
return db.oneOrNone(
"SELECT true as like FROM building_user_likes WHERE building_id = $1 and user_id = $2 LIMIT 1",
[building_id, user_id]
).then(res => {

View File

@ -262,12 +262,8 @@ server.route('/building/:building_id/like.json')
}
const { building_id } = req.params;
getBuildingLikeById(building_id, req.session.user_id).then(like => {
if (typeof (like) === "undefined") {
res.send({ like: false })
return
}
// any value returned means like
res.send({ like: true })
res.send({ like: like })
}).catch(
() => res.send({ error: 'Database error' })
)