Skip to content

feat: add timestamp fields to picker API entries#24

Merged
Cassin01 merged 1 commit into
mainfrom
docs/sort-memos-by-updated-at
Feb 16, 2026
Merged

feat: add timestamp fields to picker API entries#24
Cassin01 merged 1 commit into
mainfrom
docs/sort-memos-by-updated-at

Conversation

@Cassin01
Copy link
Copy Markdown
Owner

Add created_at and updated_at to all API entry tables (get_memos, get_memos_by_tag, get_memos_for_link) for picker sorting support.

  • parse_date_to_timestamp: extract epoch time from YYYYMMDD_HHMMSS filenames
  • get_file_mtime: read file modification time via vim.uv.fs_stat
  • Document Picker API in vim help (doc/sm.txt)

Summary

Brief description of the changes in this PR.

Related Issue

Fixes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the project's code style (Fennel, not Lua directly)
  • I have run make to regenerate Lua files
  • I have run make test and all tests pass
  • I have added tests for new functionality
  • I have updated the documentation (if needed)

Testing

Describe how you tested your changes:

Screenshots (if applicable)

Add screenshots to help explain your changes.

Add created_at and updated_at to all API entry tables (get_memos,
get_memos_by_tag, get_memos_for_link) for picker sorting support.

- parse_date_to_timestamp: extract epoch time from YYYYMMDD_HHMMSS filenames
- get_file_mtime: read file modification time via vim.uv.fs_stat
- Document Picker API in vim help (doc/sm.txt)
Copilot AI review requested due to automatic review settings February 16, 2026 05:30
@Cassin01 Cassin01 merged commit 46e6760 into main Feb 16, 2026
6 checks passed
Copy link
Copy Markdown
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 extends the picker-facing API entries with created_at and updated_at timestamps to support picker-side sorting, and updates tests/docs accordingly.

Changes:

  • Add timestamp extraction (created_at from filename, updated_at from filesystem mtime) to memo metadata.
  • Thread created_at/updated_at through picker API entry tables and update API/memo tests.
  • Document the Picker API entry schema in doc/sm.txt.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fnl/sm/memo.fnl Adds timestamp helpers and includes created_at/updated_at in get_memo_info.
fnl/sm/api.fnl Adds timestamps to picker entry tables returned by API list functions.
fnl/sm/memo_test.fnl Adds tests for date parsing + timestamp fields; stubs vim.uv.fs_stat.
fnl/sm/api_test.fnl Updates API mocks/assertions to include timestamp fields.
lua/sm/memo.lua Generated Lua reflecting new timestamp logic in memo module.
lua/sm/api.lua Generated Lua reflecting new timestamp fields in API entries.
lua/sm/memo_test.lua Generated Lua reflecting updated memo tests/mocks.
lua/sm/api_test.lua Generated Lua reflecting updated API tests/mocks.
doc/sm.txt Adds a “Picker API” help section documenting entry fields including timestamps.
.gitignore Adds .macot (appears unrelated to PR goal).

Comment thread fnl/sm/memo.fnl
Comment on lines +20 to +25
(os.time {:year (tonumber year)
:month (tonumber month)
:day (tonumber day)
:hour (tonumber hour)
:min (tonumber min)
:sec (tonumber sec)})))))
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

parse_date_to_timestamp will accept any 6 numeric components that match the pattern, but os.time normalizes out-of-range values (e.g. month=13, hour=99) instead of failing. That means clearly-invalid filenames could produce a non-nil created_at that is incorrect. Consider validating ranges (and ideally round-tripping with os.date to ensure the resulting fields match the parsed fields) and returning nil when the date/time is not a real YYYYMMDD_HHMMSS.

Suggested change
(os.time {:year (tonumber year)
:month (tonumber month)
:day (tonumber day)
:hour (tonumber hour)
:min (tonumber min)
:sec (tonumber sec)})))))
(let [year-num (tonumber year)
month-num (tonumber month)
day-num (tonumber day)
hour-num (tonumber hour)
min-num (tonumber min)
sec-num (tonumber sec)]
;; Basic range validation to avoid obvious invalid dates/times
(when (and year-num
month-num (>= month-num 1) (<= month-num 12)
day-num (>= day-num 1) (<= day-num 31)
hour-num (>= hour-num 0) (<= hour-num 23)
min-num (>= min-num 0) (<= min-num 59)
sec-num (>= sec-num 0) (<= sec-num 59))
(let [ts (os.time {:year year-num
:month month-num
:day day-num
:hour hour-num
:min min-num
:sec sec-num})]
;; Round-trip via os.date to ensure os.time didn't normalize
(when ts
(let [t (os.date "*t" ts)]
(when (and (= t.year year-num)
(= t.month month-num)
(= t.day day-num)
(= t.hour hour-num)
(= t.min min-num)
(= t.sec sec-num))
ts)))))))))

Copilot uses AI. Check for mistakes.
Comment thread fnl/sm/memo.fnl
Comment on lines +214 to +215
created_at (parse_date_to_timestamp date_part)
updated_at (get_file_mtime filepath)]
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

get_memo_info now calls uv.fs_stat (via get_file_mtime) for every memo, which adds a synchronous filesystem stat per entry. For large memo collections this can noticeably slow picker population. Consider making updated_at optional/lazy (computed in the picker integration layer only when needed), or caching stat results during a single listing call to avoid repeated stats.

Copilot uses AI. Check for mistakes.
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.

2 participants