From 1aa6018d094091d54040806c4be7021924ea3801 Mon Sep 17 00:00:00 2001 From: Paul Tran-Van Date: Tue, 15 Oct 2024 15:51:58 +0200 Subject: [PATCH] feat: Add lastUpdated attribute to search index This might be useful to know when a search index had been updated --- src/search/SearchEngine.ts | 4 +++- src/search/types.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/search/SearchEngine.ts b/src/search/SearchEngine.ts index e0d70da..957e196 100644 --- a/src/search/SearchEngine.ts +++ b/src/search/SearchEngine.ts @@ -179,7 +179,8 @@ class SearchEngine { this.searchIndexes[doctype] = { index, - lastSeq: info?.update_seq + lastSeq: info?.update_seq, + lastUpdated: new Date().toISOString() } return this.searchIndexes[doctype] } @@ -204,6 +205,7 @@ class SearchEngine { } searchIndex.lastSeq = changes.last_seq + searchIndex.lastUpdated = new Date().toISOString() return searchIndex } diff --git a/src/search/types.ts b/src/search/types.ts index 4bcf3cd..83fb8e5 100644 --- a/src/search/types.ts +++ b/src/search/types.ts @@ -47,7 +47,8 @@ export interface SearchResult { export interface SearchIndex { index: FlexSearch.Document - lastSeq: number + lastSeq: number | null + lastUpdated: string } export type SearchIndexes = {