최은석

fix waiting with showing chat within 1 hour

......@@ -185,8 +185,22 @@ router.get('/api/waiting', async (req, res) => {
const today = getCurrentDate();
var waitingList = await waitingModel.findOne({ date: today });
if (waitingList == null) waitingList = []
else waitingList = waitingList. waiting;
res.send(waitingList);
else waitingList = waitingList.waiting;
const date = new Date();
var hour = date.getHours();
hour = hour < 10 ? '0' + hour.toString() : hour.toString();
var minute = date.getMinutes();
minute = minute < 10 ? '0' + minute.toString() : minute.toString();
const time = Number(hour + minute);
var result = [];
for(const waiting of waitingList){
if(time - Number(waiting.time.replace(':','')) <= 100){
result.push(waiting)
}
}
res.send(result);
}
catch (err) {
res.send(err.message);
......@@ -199,7 +213,11 @@ router.post('/api/waiting', async (req, res) => {
var waitingList = await waitingModel.findOne({ date: today });
const date = new Date();
const time = date.getHours() + ":" + date.getMinutes();
var hour = date.getHours();
hour = hour < 10 ? '0' + hour.toString() : hour.toString();
var minute = date.getMinutes();
minute = minute < 10 ? '0' + minute.toString() : minute.toString();
const time = hour + ":" + minute;
const newWaiting = {value: req.body.value, time: time};
if (waitingList == null) await waitingModel({date: today, waiting: [newWaiting]}).save();
......@@ -217,6 +235,7 @@ router.post('/api/waiting', async (req, res) => {
});
function setting(resultJson){
var result = {}
result.fo_date = [resultJson.fo_date1, resultJson.fo_date2, resultJson.fo_date3, resultJson.fo_date4, resultJson.fo_date5];
......