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)
|
||||
|
||||
if data['data'].isnumeric():
|
||||
models.ScanLog.add_log(data['data'])
|
||||
bark_push('扫码成功', '条形码 %s' % data['data'])
|
||||
else:
|
||||
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)
|
||||
|
||||
# Query logs for today
|
||||
return cls.objects.filter(
|
||||
scan_at__gte=today_start,
|
||||
scan_at__lte=today_end
|
||||
).order_by('-scan_at')
|
||||
return cls.select().where(cls.scan_at.between(today_start, today_end))
|
||||
|
||||
def serialize(self):
|
||||
# Try to get product info from BarcodeDB
|
||||
@ -52,6 +49,10 @@ class ScanLog(BaseModel):
|
||||
'scan_at': self.scan_at
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def add_log(cls, barcode):
|
||||
# Add log to database
|
||||
cls.create(barcode=barcode)
|
||||
|
||||
|
||||
# Create tables
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user