Add Filter builder, Archive/Unarchive, WithRepeat, and GoDoc examples

- Implement client-side Filter builder with tag, status, due date, and search filters
- Add unit tests for Filter with performance benchmark
- Add Archive/Unarchive methods to ChecklistService
- Add WithRepeat method to TaskBuilder for recurring tasks
- Create GoDoc examples for all major functionality
This commit is contained in:
Oliver Jakoubek 2026-01-14 14:39:27 +01:00
commit cb30b178be
7 changed files with 793 additions and 10 deletions

View file

@ -60,6 +60,7 @@ type CreateTaskRequest struct {
Due string `json:"due,omitempty"`
Priority int `json:"priority,omitempty"`
Tags string `json:"tags,omitempty"`
Repeat string `json:"repeat,omitempty"`
}
// TaskBuilder provides a fluent interface for building task creation requests.
@ -70,6 +71,7 @@ type TaskBuilder struct {
due string
priority int
tags []string
repeat string
}
// NewTask creates a new TaskBuilder with the given content.
@ -107,6 +109,21 @@ func (b *TaskBuilder) WithTags(tags ...string) *TaskBuilder {
return b
}
// WithRepeat sets the repeat pattern for the task using Checkvist's smart syntax.
// Common patterns include:
// - "daily" - repeats every day
// - "weekly" - repeats every week
// - "monthly" - repeats every month
// - "yearly" - repeats every year
// - "every 2 days" - repeats every 2 days
// - "every week on monday" - repeats weekly on Monday
// - "every month on 15" - repeats monthly on the 15th
// - "every 2 weeks on friday" - repeats every 2 weeks on Friday
func (b *TaskBuilder) WithRepeat(pattern string) *TaskBuilder {
b.repeat = pattern
return b
}
// build converts the TaskBuilder to a CreateTaskRequest.
func (b *TaskBuilder) build() CreateTaskRequest {
req := CreateTaskRequest{
@ -115,6 +132,7 @@ func (b *TaskBuilder) build() CreateTaskRequest {
Position: b.position,
Due: b.due,
Priority: b.priority,
Repeat: b.repeat,
}
if len(b.tags) > 0 {
for i, tag := range b.tags {