From 56744dbd5bb5b4b0081ef43059b846fb5259e843 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Thu, 30 Jul 2026 07:35:55 +0200 Subject: [PATCH 1/2] Fixed modifiedAfter for tickets and milestones, so it filters on the modified timestamp --- CHANGELOG.md | 4 ++++ Repositories/ApiDataRepository.php | 8 ++++---- Services/APIData.php | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bfa34e..d0619b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +* [PR-15](https://github.com/ITK-Leantime/data-api/pull/15) + * Fixed modifiedAfter for tickets and milestones, so it filters on the modified timestamp + instead of the creation date. Edits to older tickets and milestones now sync. + ## [0.1.2] - 2026-03-06 * [PR-12](https://github.com/ITK-Leantime/data-api/pull/12) diff --git a/Repositories/ApiDataRepository.php b/Repositories/ApiDataRepository.php index f5cc80a..8783dd1 100644 --- a/Repositories/ApiDataRepository.php +++ b/Repositories/ApiDataRepository.php @@ -28,14 +28,14 @@ public function getProjects(int $startId, int $limit, ?int $modifiedAfter = null ->toArray(); } - public function getMilestones(int $startId, int $limit, int $modifiedAfter = null, ?array $ids = null, ?array $projectIds = null): array + public function getMilestones(int $startId, int $limit, ?int $modifiedAfter = null, ?array $ids = null, ?array $projectIds = null): array { return $this->query() ->select(["id", "headline", "projectId", "modified"]) ->from("zp_tickets", "ticket") ->where("ticket.id", ">=", $startId) ->where("ticket.type", "=", "milestone") - ->when($modifiedAfter !== null, fn ($query) => $query->where("ticket.date", ">=", CarbonImmutable::createFromTimestamp($modifiedAfter)->format(APIData::DATE_FORMAT))) + ->when($modifiedAfter !== null, fn ($query) => $query->where("ticket.modified", ">=", CarbonImmutable::createFromTimestamp($modifiedAfter)->format(APIData::DATE_FORMAT))) ->when($ids !== null, fn ($query) => $query->whereIn("ticket.id", $ids)) ->when($projectIds != null, fn ($query) => $query->whereIn("ticket.projectId", $projectIds)) ->orderBy("id", "ASC") @@ -44,7 +44,7 @@ public function getMilestones(int $startId, int $limit, int $modifiedAfter = nul ->toArray(); } - public function getTickets(int $startId, int $limit, int $modifiedAfter = null, array $ids = null, ?array $projectIds = null): array + public function getTickets(int $startId, int $limit, ?int $modifiedAfter = null, ?array $ids = null, ?array $projectIds = null): array { return $this->query() ->select(["ticket.id", "ticket.headline", "ticket.projectId", "ticket.status", "ticket.planHours", "ticket.hourRemaining", "ticket.tags", "ticket.dateToFinish", "ticket.editTo", "ticket.milestoneid", "ticket.modified", "user.username"]) @@ -52,7 +52,7 @@ public function getTickets(int $startId, int $limit, int $modifiedAfter = null, ->where("ticket.id", ">=", $startId) ->where("ticket.type", "<>", "milestone") ->leftJoin('zp_user as user', "user.id", "=", "ticket.editorId") - ->when($modifiedAfter !== null, fn ($query) => $query->where("ticket.date", ">=", CarbonImmutable::createFromTimestamp($modifiedAfter)->format(APIData::DATE_FORMAT))) + ->when($modifiedAfter !== null, fn ($query) => $query->where("ticket.modified", ">=", CarbonImmutable::createFromTimestamp($modifiedAfter)->format(APIData::DATE_FORMAT))) ->when($ids !== null, fn ($query) => $query->whereIn("ticket.id", $ids)) ->when($projectIds != null, fn ($query) => $query->whereIn("ticket.projectId", $projectIds)) ->orderBy("id", "ASC") diff --git a/Services/APIData.php b/Services/APIData.php index 8929f87..d0d9dc2 100644 --- a/Services/APIData.php +++ b/Services/APIData.php @@ -125,7 +125,7 @@ public function getProjects(int $startId, int $limit, ?int $modifiedAfter = null }, $values); } - public function getMilestones(int $startId, int $limit, int $modifiedAfter = null, ?array $ids = null, ?array $projectIds = null): array + public function getMilestones(int $startId, int $limit, ?int $modifiedAfter = null, ?array $ids = null, ?array $projectIds = null): array { $values = $this->apiDataRepository->getMilestones($startId, $limit, $modifiedAfter, $ids, $projectIds); @@ -139,7 +139,7 @@ public function getMilestones(int $startId, int $limit, int $modifiedAfter = nul }, $values); } - public function getTickets(int $startId, int $limit, int $modifiedAfter = null, array $ids = null, ?array $projectIds = null): array + public function getTickets(int $startId, int $limit, ?int $modifiedAfter = null, ?array $ids = null, ?array $projectIds = null): array { $values = $this->apiDataRepository->getTickets($startId, $limit, $modifiedAfter, $ids, $projectIds); From 062d5381f0a7afca5aa795fffe53bf6fd9ae96e7 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Thu, 30 Jul 2026 07:36:31 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0619b4..0c0a927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [Unreleased] -* [PR-15](https://github.com/ITK-Leantime/data-api/pull/15) +* [PR-17](https://github.com/ITK-Leantime/data-api/pull/17) * Fixed modifiedAfter for tickets and milestones, so it filters on the modified timestamp instead of the creation date. Edits to older tickets and milestones now sync.