Compare commits
No commits in common. "40129961a04854f9563b97642f8463334c9746ff" and "fe4be1b06ef1ccdb19b873e49b68ab54cfe7585f" have entirely different histories.
40129961a0
...
fe4be1b06e
1
app.py
1
app.py
@ -531,7 +531,6 @@ 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,7 +31,10 @@ 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.select().where(cls.scan_at.between(today_start, today_end))
|
return cls.objects.filter(
|
||||||
|
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
|
||||||
@ -49,10 +52,6 @@ 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