fix(models): 优化ScanLog查询方法

简化ScanLog模型中查询今天日志的方法,使用更简洁的ORM查询方式。
This commit is contained in:
Ching 2025-02-09 18:14:59 +08:00
parent fe4be1b06e
commit d8887eaf5b

View File

@ -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