62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
"""Find all feb26-tagged Press Release tasks regardless of due date or status."""
|
|
|
|
import logging
|
|
from datetime import UTC, datetime
|
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s", datefmt="%H:%M:%S")
|
|
|
|
from cheddahbot.config import load_config
|
|
from cheddahbot.clickup import ClickUpClient
|
|
|
|
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
|
|
|
|
# Query ALL statuses (no status filter, no due date filter) but filter by Press Release
|
|
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
|
|
)
|
|
|
|
import json
|
|
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]}]
|
|
)
|
|
|
|
# Get tasks with NO status filter and NO due date filter
|
|
tasks = client.get_tasks_from_space(
|
|
space_id,
|
|
statuses=["to do", "outline approved", "in progress", "automation underway"],
|
|
custom_fields=custom_fields_filter,
|
|
)
|
|
|
|
# Filter for feb26 tag
|
|
feb26_tasks = [t for t in tasks if "feb26" in t.tags]
|
|
all_pr = [t for t in tasks if t.task_type == "Press Release"]
|
|
|
|
print(f"\n{'='*70}")
|
|
print(f"Total tasks returned: {len(tasks)}")
|
|
print(f"Press Release tasks: {len(all_pr)}")
|
|
print(f"feb26-tagged PR tasks: {len(feb26_tasks)}")
|
|
print(f"{'='*70}\n")
|
|
|
|
for t in all_pr:
|
|
due = ""
|
|
if t.due_date:
|
|
try:
|
|
due_dt = datetime.fromtimestamp(int(t.due_date) / 1000, tz=UTC)
|
|
due = due_dt.strftime("%Y-%m-%d")
|
|
except (ValueError, TypeError):
|
|
due = t.due_date
|
|
tags_str = ", ".join(t.tags) if t.tags else "(no tags)"
|
|
customer = t.custom_fields.get("Customer", "?")
|
|
print(f" [{t.status:20s}] {t.name}")
|
|
print(f" id={t.id} due={due or '(none)'} tags={tags_str} customer={customer}")
|
|
print()
|