Parse swipe timestamp format
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
59d756a845
commit
43776722a1
@ -1,4 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.parser import parse
|
||||
|
||||
from bson.objectid import ObjectId
|
||||
from flask import Blueprint, g, redirect, render_template, request
|
||||
@ -223,6 +224,7 @@ class FormSwipe(FlaskForm):
|
||||
def view_swipe():
|
||||
form = request.json
|
||||
print(form)
|
||||
timestamp = parse(form["timestamp"]) if form.get("timestamp") else None
|
||||
now = datetime.utcnow()
|
||||
# Make sure token exists
|
||||
db.inventory.update_one({
|
||||
@ -231,7 +233,7 @@ def view_swipe():
|
||||
"token.uid_hash": form["uid_hash"]
|
||||
}, {
|
||||
"$set": {
|
||||
"last_seen": form.get("timestamp", now)
|
||||
"last_seen": timestamp or now
|
||||
},
|
||||
"$setOnInsert": {
|
||||
"component": "doorboy",
|
||||
@ -252,7 +254,7 @@ def view_swipe():
|
||||
|
||||
event_swipe = {
|
||||
"component": "doorboy",
|
||||
"timestamp": form["timestamp"],
|
||||
"timestamp": timestamp,
|
||||
"door": form["door"],
|
||||
"event": "card-swiped",
|
||||
"success": form["success"],
|
||||
|
@ -13,5 +13,6 @@ sepa
|
||||
Flask-WTF
|
||||
prometheus-flask-exporter
|
||||
pymongo
|
||||
python-dateutil
|
||||
pyjwt[crypto]
|
||||
kubernetes
|
||||
|
Loading…
Reference in New Issue
Block a user