65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
"""Find all Press Release tasks due in February 2026, any status."""
|
|
|
|
import logging
|
|
from datetime import UTC, datetime
|
|
|
|
logging.basicConfig(level=logging.WARNING)
|
|
|
|
from cheddahbot.config import load_config
|
|
from cheddahbot.clickup import ClickUpClient
|
|
import json
|
|
|
|
config = load_config()
|
|
client = ClickUpClient(
|
|
api_token=config.clickup.api_token,
|
|
workspace_id=config.clickup.workspace_id,
|
|
task_type_field_name=config.clickup.task_type_field_name,
|
|
)
|
|
|
|
space_id = config.clickup.space_id
|
|
list_ids = client.get_list_ids_from_space(space_id)
|
|
field_filter = client.discover_field_filter(
|
|
next(iter(list_ids)), config.clickup.task_type_field_name
|
|
)
|
|
|
|
pr_opt_id = field_filter["options"]["Press Release"]
|
|
custom_fields_filter = json.dumps(
|
|
[{"field_id": field_filter["field_id"], "operator": "ANY", "value": [pr_opt_id]}]
|
|
)
|
|
|
|
# February 2026 window
|
|
feb_start = int(datetime(2026, 2, 1, tzinfo=UTC).timestamp() * 1000)
|
|
feb_end = int(datetime(2026, 3, 1, tzinfo=UTC).timestamp() * 1000)
|
|
|
|
# Query with broad statuses, include closed
|
|
tasks = client.get_tasks_from_space(
|
|
space_id,
|
|
custom_fields=custom_fields_filter,
|
|
)
|
|
|
|
# Filter for due in February 2026
|
|
feb_prs = []
|
|
for t in tasks:
|
|
if t.task_type != "Press Release":
|
|
continue
|
|
if not t.due_date:
|
|
continue
|
|
try:
|
|
due_ms = int(t.due_date)
|
|
if feb_start <= due_ms < feb_end:
|
|
feb_prs.append(t)
|
|
except (ValueError, TypeError):
|
|
continue
|
|
|
|
print(f"\nPress Release tasks due in February 2026: {len(feb_prs)}\n")
|
|
for t in feb_prs:
|
|
due_dt = datetime.fromtimestamp(int(t.due_date) / 1000, tz=UTC)
|
|
due = due_dt.strftime("%Y-%m-%d")
|
|
tags_str = ", ".join(t.tags) if t.tags else "(none)"
|
|
customer = t.custom_fields.get("Customer", "?")
|
|
imsurl = t.custom_fields.get("IMSURL", "")
|
|
print(f" [{t.status:20s}] {t.name}")
|
|
print(f" id={t.id} due={due} tags={tags_str}")
|
|
print(f" customer={customer} imsurl={imsurl or '(none)'}")
|
|
print()
|