Include edit history in building data from API
This commit is contained in:
parent
4f16130d47
commit
39be3507a2
@ -79,12 +79,31 @@ function getBuildingById(id) {
|
|||||||
return db.one(
|
return db.one(
|
||||||
'SELECT * FROM buildings WHERE building_id = $1',
|
'SELECT * FROM buildings WHERE building_id = $1',
|
||||||
[id]
|
[id]
|
||||||
).catch(function (error) {
|
).then((building) => {
|
||||||
|
return getBuildingEditHistory(id).then((edit_history) => {
|
||||||
|
building.edit_history = edit_history
|
||||||
|
return building
|
||||||
|
})
|
||||||
|
}).catch(function (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBuildingEditHistory(id) {
|
||||||
|
return db.manyOrNone(
|
||||||
|
`SELECT log_id as revision_id, forward_patch, reverse_patch, date_trunc('minute', log_timestamp), username
|
||||||
|
FROM logs, users
|
||||||
|
WHERE building_id = $1 AND logs.user_id = users.user_id`,
|
||||||
|
[id]
|
||||||
|
).then((data) => {
|
||||||
|
return data
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.error(error);
|
||||||
|
return []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getBuildingLikeById(buildingId, userId) {
|
function getBuildingLikeById(buildingId, userId) {
|
||||||
return db.oneOrNone(
|
return db.oneOrNone(
|
||||||
'SELECT true as like FROM building_user_likes WHERE building_id = $1 and user_id = $2 LIMIT 1',
|
'SELECT true as like FROM building_user_likes WHERE building_id = $1 and user_id = $2 LIMIT 1',
|
||||||
|
Loading…
Reference in New Issue
Block a user