time calculation logic added

This commit is contained in:
Dawid Kubicki 2019-01-12 21:07:32 +01:00
parent cb482bce13
commit 554b17a589

View File

@ -94,6 +94,18 @@ app.get("/stop", (req, res) => {
res.json({ message: "Przestalem dzialac :<" }); res.json({ message: "Przestalem dzialac :<" });
}); });
app.get("/status/:id", async (req, res) => {
const data = await statusSchema
.findOne({
device: mongoose.Types.ObjectId(req.params.id)
})
.select("status");
const status = data.status.sort((a, b) => {
return b.time - a.time;
});
res.json(status);
});
app.get("/start", (req, res) => { app.get("/start", (req, res) => {
if (interval === null) { if (interval === null) {
interval = setInterval(() => { interval = setInterval(() => {