diff --git a/src/metabase/models/dashboard.clj b/src/metabase/models/dashboard.clj index 590526a7c4154066760a84c39e26bf8efe6c01a0..268d6d2f8f8ad57ea31cdafd852428246c1bb10c 100644 --- a/src/metabase/models/dashboard.clj +++ b/src/metabase/models/dashboard.clj @@ -672,6 +672,7 @@ :database-id false :last-editor-id :r.user_id :last-edited-at :r.timestamp + :last-viewed-at true :pinned [:> [:coalesce :collection_position [:inline 0]] [:inline 0]] :view-count true :created-at true diff --git a/src/metabase/search/postgres/index.clj b/src/metabase/search/postgres/index.clj index d0ffffe3d640e46f447b9a7803479093f7b69375..9dd5c6bff39df581126615c7799b5cfed6d84a83 100644 --- a/src/metabase/search/postgres/index.clj +++ b/src/metabase/search/postgres/index.clj @@ -53,6 +53,7 @@ [:legacy_input :text :not-null] ;; scoring related [:dashboardcard_count :int] + [:last_viewed_at :timestamp] [:model_rank :int :not-null] [:official_collection :boolean] [:pinned :boolean] diff --git a/src/metabase/search/postgres/scoring.clj b/src/metabase/search/postgres/scoring.clj index 1d4f196efc8031717bb7cde56302fa2295873b38..877598bbbc0ef28f15f8de8ff63fadd6561d80ec 100644 --- a/src/metabase/search/postgres/scoring.clj +++ b/src/metabase/search/postgres/scoring.clj @@ -80,7 +80,7 @@ :view-count (atan-size :view_count search.config/view-count-scaling) :pinned (truthy :pinned) :bookmarked bookmark-score-expr - :recency (inverse-duration :model_updated_at [:now] search.config/stale-time-in-days) + :recency (inverse-duration [:coalesce :last_viewed_at :model_updated_at] [:now] search.config/stale-time-in-days) :dashboard (size :dashboardcard_count search.config/dashboard-count-ceiling) :model (idx-rank :model_rank (count search.config/all-models))}) diff --git a/src/metabase/search/spec.clj b/src/metabase/search/spec.clj index 8a8e69984e1d59d60d1d3477a408b59be2b82c57..151065395a505fdd513954eba526292bc3966e78 100644 --- a/src/metabase/search/spec.clj +++ b/src/metabase/search/spec.clj @@ -38,6 +38,7 @@ :name :official-collection :dashboardcard-count + :last-viewed-at :pinned :verified ;; in addition to being a filter, this is also a ranker :view-count