Compare commits
2 Commits
fe4be1b06e
...
40129961a0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40129961a0 | ||
|
|
d8887eaf5b |
1
app.py
1
app.py
@ -531,6 +531,7 @@ def add_to_stream():
|
|||||||
stream_id = r.xadd(STREAM_KEY, data)
|
stream_id = r.xadd(STREAM_KEY, data)
|
||||||
|
|
||||||
if data['data'].isnumeric():
|
if data['data'].isnumeric():
|
||||||
|
models.ScanLog.add_log(data['data'])
|
||||||
bark_push('扫码成功', '条形码 %s' % data['data'])
|
bark_push('扫码成功', '条形码 %s' % data['data'])
|
||||||
else:
|
else:
|
||||||
bark_push('扫码成功', '二维码 %s' % data['data'])
|
bark_push('扫码成功', '二维码 %s' % data['data'])
|
||||||
|
|||||||
@ -31,10 +31,7 @@ class ScanLog(BaseModel):
|
|||||||
today_end = datetime.combine(today, time.max) # End of day (23:59:59.999999)
|
today_end = datetime.combine(today, time.max) # End of day (23:59:59.999999)
|
||||||
|
|
||||||
# Query logs for today
|
# Query logs for today
|
||||||
return cls.objects.filter(
|
return cls.select().where(cls.scan_at.between(today_start, today_end))
|
||||||
scan_at__gte=today_start,
|
|
||||||
scan_at__lte=today_end
|
|
||||||
).order_by('-scan_at')
|
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
# Try to get product info from BarcodeDB
|
# Try to get product info from BarcodeDB
|
||||||
@ -52,6 +49,10 @@ class ScanLog(BaseModel):
|
|||||||
'scan_at': self.scan_at
|
'scan_at': self.scan_at
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def add_log(cls, barcode):
|
||||||
|
# Add log to database
|
||||||
|
cls.create(barcode=barcode)
|
||||||
|
|
||||||
|
|
||||||
# Create tables
|
# Create tables
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user