feat: 采集任务可按即席查询分类选表,并按相对时间导出 CSV
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
from datetime import date
|
||||
|
||||
from app.nqi.adhoc import time_window
|
||||
|
||||
|
||||
def test_relative_windows_from_a_monday():
|
||||
today = date(2026, 11, 9)
|
||||
assert _span("prev_month", 1, today) == ("2026-10-01", "2026-10-31")
|
||||
assert _span("prev_week", 1, today) == ("2026-11-02", "2026-11-08")
|
||||
assert _span("prev_day", 1, today) == ("2026-11-08", "2026-11-08")
|
||||
assert _span("prev_days", 3, today) == ("2026-11-06", "2026-11-08")
|
||||
assert _span("prev_weeks", 2, today) == ("2026-10-26", "2026-11-08")
|
||||
assert _span("prev_months", 2, today) == ("2026-09-01", "2026-10-31")
|
||||
|
||||
|
||||
def _span(mode: str, count: int, today: date) -> tuple[str, str]:
|
||||
start, end = time_window(mode, count, today)
|
||||
return start.strftime("%Y-%m-%d"), end.strftime("%Y-%m-%d")
|
||||
Reference in New Issue
Block a user