Skip to content

Conversation

@dkhalife
Copy link
Owner

Summary

  • add TaskRepository.GetCompletedTasks with pagination
  • expose GET /completed endpoint in task API
  • add tests for GetCompletedTasks
  • simplify error responses and add out-of-bounds pagination test

Testing

  • go test ./...

https://chatgpt.com/codex/tasks/task_e_6861c8d83fa0832abdbd0901510846e1

Copilot AI review requested due to automatic review settings June 30, 2025 02:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for listing completed tasks with pagination in both the repository layer and HTTP API, and includes tests for the new functionality.

  • Introduces GetCompletedTasks in TaskRepository with pagination parameters.
  • Exposes a new GET /completed endpoint in the Tasks API with query parameters limit and page.
  • Adds TestGetCompletedTasks in the repository tests and includes an out-of-bounds pagination case.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/repos/task/task.go Added GetCompletedTasks method with pagination and label preloading.
internal/repos/task/task_test.go New TestGetCompletedTasks covering pagination and empty results.
internal/apis/task.go New handler getCompletedTasks, query parsing, and route registration for /completed.
Comments suppressed due to low confidence (3)

internal/apis/task.go:80

  • [nitpick] Returning only c.Status(http.StatusBadRequest) without a response body may be inconsistent with other endpoints; consider returning a JSON error message for clarity.
	if err != nil || limit <= 0 {

internal/apis/task.go:79

  • Make sure the strconv package (and net/http for status codes) is imported so these calls compile successfully.
	limit, err := strconv.Atoi(limitStr)

internal/repos/task/task_test.go:564

  • [nitpick] This explicit update is redundant since the task was created with IsActive: false already; you can remove the extra update for clarity.
		err = s.DB.Model(&models.Task{}).Where("id = ?", t.ID).Update("is_active", false).Error

@codecov
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 23.25581% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/apis/task.go 0.00% 30 Missing ⚠️
internal/repos/task/task.go 76.92% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@dkhalife dkhalife merged commit e972f12 into main Jun 30, 2025
5 checks passed
@dkhalife dkhalife deleted the y3oqzw-codex/add-api-for-completed-tasks-with-pagination branch June 30, 2025 03:13
dkhalife added a commit that referenced this pull request Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants