Merge branch 'feature/show_edit_history'
This commit is contained in:
commit
12f31bc585
@ -79,12 +79,31 @@ function getBuildingById(id) {
|
||||
return db.one(
|
||||
'SELECT * FROM buildings WHERE building_id = $1',
|
||||
[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);
|
||||
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) {
|
||||
return db.oneOrNone(
|
||||
'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