search: фильтры created_ts переведены на timestamp для memos 0.30

В memos 0.30.0 поле created_ts в CEL стало типом timestamp, и сравнение
с Unix-числом перестало компилироваться. Границы диапазона теперь
формируются как timestamp("<RFC3339>") в UTC.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
av
2026-08-06 12:21:53 +03:00
co-authored by Claude Opus 5
parent c3acb50fcc
commit 8e8cc990c4
2 changed files with 14 additions and 4 deletions
+9 -2
View File
@@ -13,9 +13,16 @@ type DateRange struct {
} }
// BuildCELFilter creates a CEL filter string for a date range using created_ts. // BuildCELFilter creates a CEL filter string for a date range using created_ts.
// Since memos 0.30 created_ts is a CEL timestamp, so plain Unix ints are not
// comparable with it — the bounds must be wrapped in timestamp().
func BuildCELFilter(dr DateRange) string { func BuildCELFilter(dr DateRange) string {
return fmt.Sprintf("created_ts >= %d && created_ts < %d", return fmt.Sprintf("created_ts >= timestamp(%q) && created_ts < timestamp(%q)",
dr.Start.Unix(), dr.End.Unix()) formatCELTimestamp(dr.Start), formatCELTimestamp(dr.End))
}
// formatCELTimestamp renders a time as an RFC3339 literal in UTC.
func formatCELTimestamp(t time.Time) string {
return t.UTC().Format(time.RFC3339)
} }
func isLeapYear(year int) bool { func isLeapYear(year int) bool {
+5 -2
View File
@@ -16,10 +16,13 @@ GET /api/v1/memos?filter={CEL}&pageSize={N}
### Фильтрация по дате ### Фильтрация по дате
API поддерживает CEL-фильтры по полю `created_ts` (Unix timestamp): API поддерживает CEL-фильтры по полю `created_ts`. Начиная с memos 0.30.0 это
значение типа `timestamp`, поэтому границы диапазона задаются через
`timestamp("<RFC3339>")` (в UTC); сравнение с голым Unix-числом больше не
компилируется:
``` ```
created_ts >= 1707696000 && created_ts < 1707782400 created_ts >= timestamp("2024-02-12T00:00:00Z") && created_ts < timestamp("2024-02-13T00:00:00Z")
``` ```
В качестве даты заметки используем `create_time` (поле `createTime` в JSON). В качестве даты заметки используем `create_time` (поле `createTime` в JSON).