update maxCompare

This commit is contained in:
dongpd 2020-02-06 09:45:50 +07:00
parent b56d26d5c1
commit 51b76e56f2

View File

@ -61,6 +61,7 @@ const db = makeDb(config);
var currentIn = []; var currentIn = [];
var currentOut = []; var currentOut = [];
var maxCompare = 5;
exports.SaveLogs = async function (req, res) { exports.SaveLogs = async function (req, res) {
@ -125,13 +126,13 @@ exports.SaveLogs = async function (req, res) {
} }
if (canSaveLogs) { if (canSaveLogs) {
if (req.body.type === "in") { if (req.body.type === "in") {
if (currentIn.length >= 10) { if (currentIn.length >= maxCompare) {
currentIn.shift(); currentIn.shift();
} }
currentIn.push({"plate": req.body.plate, "time": currentTimestamp}); currentIn.push({"plate": req.body.plate, "time": currentTimestamp});
} }
if (req.body.type === "out") { if (req.body.type === "out") {
if (currentOut.length >= 10) { if (currentOut.length >= maxCompare) {
currentOut.shift(); currentOut.shift();
} }
currentOut.push({"plate": req.body.plate, "time": currentTimestamp}); currentOut.push({"plate": req.body.plate, "time": currentTimestamp});