include unscheduled use between reservations
This commit is contained in:
@@ -344,8 +344,33 @@ const getLockEntryForReservation = (reservation, nextReservation) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getEntriesBetween = (reservation, previousReservation) => {
|
||||
const getEntriesBetween = (fromTimestamp, toTimestamp, resourceId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!fromTimestamp || !toTimestamp || !resourceId){
|
||||
resolve([]);
|
||||
}else {
|
||||
const andTimestampFilters = [];
|
||||
|
||||
if (fromTimestamp){
|
||||
andTimestampFilters.push({[Op.gt]: fromTimestamp});
|
||||
}
|
||||
if (toTimestamp){
|
||||
andTimestampFilters.push({[Op.lt]: toTimestamp});
|
||||
}
|
||||
|
||||
const filters = {
|
||||
resourceId,
|
||||
timestamp: {
|
||||
[Op.and]: andTimestampFilters,
|
||||
},
|
||||
};
|
||||
const order = [['timestamp', 'ASC']];
|
||||
|
||||
db.doorLockEvent.findAll({where: filters, order})
|
||||
.then((results) => resolve(results))
|
||||
.catch((error) => reject(error));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getLastEntryForReservation = (reservation) => {
|
||||
|
||||
Reference in New Issue
Block a user