fixed data range filtering

This commit is contained in:
Aditya Vaish 2025-10-16 10:11:35 +05:30
parent fa39176b82
commit 41d3caa8f5
2 changed files with 14 additions and 5 deletions

View file

@ -5,6 +5,7 @@ A module for retrieving data from ClickUp.
Allows fetching tasks from workspaces and lists. Allows fetching tasks from workspaces and lists.
""" """
from datetime import datetime
from typing import Any from typing import Any
import requests import requests
@ -168,13 +169,21 @@ class ClickUpConnector:
Tuple containing (tasks list, error message or None) Tuple containing (tasks list, error message or None)
""" """
try: try:
# TODO : Include date range in api request # Convert dates to Unix timestamps (milliseconds)
start_timestamp = int(datetime.strptime(start_date, "%Y-%m-%d").timestamp() * 1000)
end_timestamp = int(datetime.strptime(end_date, "%Y-%m-%d").timestamp() * 1000)
params = { params = {
"page": 0, "page": 0,
"order_by": "created", "order_by": "created",
"reverse": "true", "reverse": "true",
"subtasks": "true", "subtasks": "true",
"include_closed": str(include_closed).lower(),
# Date filtering parameters
"date_created_gt": start_timestamp,
"date_created_lt": end_timestamp,
"date_updated_gt": start_timestamp,
"date_updated_lt": end_timestamp,
} }
all_tasks = [] all_tasks = []

View file

@ -222,11 +222,11 @@ class JiraConnector:
# Build JQL query for date range # Build JQL query for date range
# Query issues that were either created OR updated within the date range # Query issues that were either created OR updated within the date range
date_filter = ( date_filter = (
f"(createdDate >= '{start_date}' AND createdDate <= '{end_date}')" f"(createdDate >= '{start_date}' AND createdDate <= '{end_date}') "
f"OR (updatedDate >= '{start_date}' AND updatedDate <= '{end_date}')"
) )
# TODO : This JQL needs some improvement to work as expected
_jql = f"{date_filter}" _jql = f"{date_filter} ORDER BY created DESC"
if project_key: if project_key:
_jql = ( _jql = (
f'project = "{project_key}" AND {date_filter} ORDER BY created DESC' f'project = "{project_key}" AND {date_filter} ORDER BY created DESC'
@ -250,7 +250,7 @@ class JiraConnector:
fields.append("comment") fields.append("comment")
params = { params = {
# "jql": "", TODO : Add a JQL query to filter from a date range "jql": _jql,
"fields": ",".join(fields), "fields": ",".join(fields),
"maxResults": 100, "maxResults": 100,
"startAt": 0, "startAt": 0,