Skip to content

Conversation

sjev
Copy link

@sjev sjev commented Jul 8, 2025

Add due date support to memos

(first part of #4823 )

image

Adds basic due date functionality for memos using @due(YYYY-MM-DD) syntax

Features:

  • Due date detection: Automatically detects @due(YYYY-MM-DD) patterns in memo content
  • Filtering: New has_due_date filter to show only memos with due dates
  • Statistics: Added due date count to filter button (like code, tasks etc)
  • Database support: Updated all database drivers (SQLite, MySQL, PostgreSQL) for due date queries

Implementation:

  • Added has_due_date field to MemoPayload.Property protobuf
  • Updated memo payload runner with regex validation for due date patterns
  • Enhanced frontend with due date filter button and statistics card
  • Added extended test coverage for due date detection

Usage:

  • Write @due(2025-01-15) in memo content to set due date
  • Click "Due" filter button to show only memos with due dates

Note: this is the very minimal functionality to add due dates to memos. NOT included yet are

  • color-coded badge rendering
  • sorting by due date for filtered results

@sjev sjev requested a review from boojack as a code owner July 8, 2025 21:36
Adds basic due date functionality for memos using @Due(YYYY-MM-DD) syntax:

- Due date detection: Automatically detects @Due(YYYY-MM-DD) patterns in memo content
- Filtering: New has_due_date filter to show only memos with due dates
- Statistics: Added due date count to user statistics display
- Database support: Updated all database drivers (SQLite, MySQL, PostgreSQL) for due date queries

Implementation:
- Added has_due_date field to MemoPayload.Property protobuf
- Updated memo payload runner with regex validation for due date patterns
- Enhanced frontend with due date filter button and statistics card
- Added comprehensive test coverage for due date detection
@sjev sjev force-pushed the contrib-due-date branch from 9bb446d to 4e52ec0 Compare July 8, 2025 21:46
@sjev sjev changed the title Contrib due date feat: basic due date support Jul 8, 2025
@boojack boojack requested a review from Copilot July 10, 2025 02:20
Copy link

@Copilot 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

Adds basic due date support to memos by detecting @due(YYYY-MM-DD) tags, exposing a new filter, updating statistics, and persisting the flag through the API and storage layers.

  • Detects @due(YYYY-MM-DD) in memo content and sets HasDueDate
  • Exposes dueDate filter in UI and API, and displays a “Due” stat card
  • Persists has_due_date through protobuf, DB queries, service logic, and adds test coverage for detection

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web/src/types/proto/google/protobuf/descriptor.ts Updated generated TS descriptor to include visibility features
web/src/types/proto/api/v1/user_service.ts Added dueDateCount to UserStats_MemoTypeStats
web/src/store/memoFilter.ts Added "dueDate" to filter factors
web/src/pages/UserProfile.tsx Added dueDate filter condition
web/src/pages/Home.tsx Added dueDate filter condition
web/src/pages/Archived.tsx Added dueDate filter condition
web/src/hooks/useStatisticsData.ts Aggregates dueDateCount in stats hook
web/src/components/StatisticsView/StatisticsView.tsx Added “Due” stat card with calendar icon
web/src/components/MemoFilters.tsx Renders label/icon for dueDate filter
store/memo.go Added HasDueDate to FindMemoPayload
store/db/sqlite/memo.go Filters by hasDueDate in SQLite query
store/db/postgres/memo.go Filters by hasDueDate in Postgres query
store/db/mysql/memo.go Filters by hasDueDate in MySQL query
server/runner/memopayload/runner_test.go Tests for hasDueDate detection
server/runner/memopayload/runner.go Implements hasDueDate with regex and validation
server/router/api/v1/user_service_stats.go Counts HasDueDate in user stats response
server/router/api/v1/memo_service_filter.go Parses has_due_date filter in service filter builder
proto/store/memo.proto Added has_due_date field to MemoPayload.Property
proto/gen/store/memo.pb.go Generated Go binding for HasDueDate
proto/gen/apidocs.swagger.yaml Added dueDateCount to API docs
proto/gen/api/v1/user_service.pb.go Generated Go binding for DueDateCount
proto/api/v1/user_service.proto Added due_date_count in UserStats message
Comments suppressed due to low confidence (1)

server/router/api/v1/memo_service_filter.go:71

  • There aren’t any unit tests verifying that the has_due_date filter expression is parsed and applied correctly. Consider adding tests for this new filter path.
		if filterExpr.HasDueDate {

@@ -103,6 +103,9 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v.HasIncompleteTasks {
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasIncompleteTasks') IS TRUE")
}
if v.HasDueDate {
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasDueDate') IS TRUE")
Copy link
Preview

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

The JSON path is using hasDueDate but the protobuf JSON tag is has_due_date. Update the path to $.property.has_due_date to match the stored JSON key.

Suggested change
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasDueDate') IS TRUE")
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.has_due_date') IS TRUE")

Copilot uses AI. Check for mistakes.

@@ -102,6 +102,9 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v.HasIncompleteTasks {
where = append(where, "(memo.payload->'property'->>'hasIncompleteTasks')::BOOLEAN IS TRUE")
}
if v.HasDueDate {
where = append(where, "(memo.payload->'property'->>'hasDueDate')::BOOLEAN IS TRUE")
Copy link
Preview

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

Postgres JSON operator should use 'has_due_date' to match the protobuf JSON field. Change ->>'hasDueDate' to ->>'has_due_date'.

Suggested change
where = append(where, "(memo.payload->'property'->>'hasDueDate')::BOOLEAN IS TRUE")
where = append(where, "(memo.payload->'property'->>'has_due_date')::BOOLEAN IS TRUE")

Copilot uses AI. Check for mistakes.

@@ -111,6 +111,9 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v.HasIncompleteTasks {
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasIncompleteTasks') IS TRUE")
}
if v.HasDueDate {
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasDueDate') IS TRUE")
Copy link
Preview

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

MySQL JSON path must reference has_due_date instead of hasDueDate to align with the JSON tag in protobuf.

Suggested change
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.hasDueDate') IS TRUE")
where = append(where, "JSON_EXTRACT(`memo`.`payload`, '$.property.has_due_date') IS TRUE")

Copilot uses AI. Check for mistakes.

// - - separator
// - 2 digit day (01-31)
// - ) suffix
dueDatePattern := regexp.MustCompile(`@due\((\d{4})-(\d{2})-(\d{2})\)`)
Copy link
Preview

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

Compiling the regex on every invocation can be expensive. Move MustCompile to a package-level var so it’s compiled once.

Suggested change
dueDatePattern := regexp.MustCompile(`@due\((\d{4})-(\d{2})-(\d{2})\)`)

Copilot uses AI. Check for mistakes.

@sjev
Copy link
Author

sjev commented Sep 2, 2025

Too many projects, too little time... sorry, closing this as I have higher priorities for coming months.

@sjev sjev closed this Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant