statistics

This commit is contained in:
xyj 2024-02-20 14:48:28 +08:00
parent 7e1c63b4ec
commit 5e76e53885
2 changed files with 8 additions and 1 deletions

6
test.py Normal file
View File

@ -0,0 +1,6 @@
from datetime import datetime, timedelta
current_date = datetime.now().date()
tomorrow = current_date + timedelta(days=1)
past_7_days_date = current_date - timedelta(days=7)
print(tomorrow)

View File

@ -336,9 +336,10 @@ async def past_seven_days(deviceId):
try: try:
current_date = datetime.now().date() current_date = datetime.now().date()
past_7_days_date = current_date - timedelta(days=7) past_7_days_date = current_date - timedelta(days=7)
tomorrow = current_date + timedelta(days=1)
if deviceId is None or deviceId == "" or len(deviceId) != 4: if deviceId is None or deviceId == "" or len(deviceId) != 4:
return BaseResponse(code=500, msg="参数错误") return BaseResponse(code=500, msg="参数错误")
sql = f"select * from root.warning.{deviceId} where time >= {past_7_days_date} and time <= {current_date}" sql = f"select * from root.warning.{deviceId} where time >= {past_7_days_date} and time <= {tomorrow}"
send_json = { send_json = {
"sql": sql "sql": sql
} }