forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authority Level on collections (formerly Typed collections) (metabase…
…#16191) * Add type on collection * Search with collection type * Cleanup bounded heap accumulator * Make search conditionally bump official collection items * collection api and tests * Put collection type onto hydrated cards on dashboards * Move official collection type scoring into ee codebase * ensure ee and oss agree when not official collection * Mark Collections tree with type * Remove unnecessary `and`s when no check for enhancements * Tests for setting collection tree type * Include hydration for collection type on dashboards * Make sure created test collections are cleaned up * Cleanup tests, don't search on collection_type looks for all text fields and searches the term against that. official would bring back all official types. no bueno * Docstring on protocol and don't shadow comparator * update to new ee impl var passing style * Collection model ensures no type change on personal collection * Check for personal collection when updating type model checks for personal collection and rejects in the update but doesn't check for children of personal collection. * Update checking for unchangeable properties of a personal collection * Cleanup: type collection tree, batched hydration, combine error checks * Cleanup * move bounded-heap accumulator to utils * switch to test.check testing * Bad test just to see what our CI will report * remove purposeful failing test (was for CI) * collection.type -> collection.authority_level * Test the actual ee scoring impl, not the wrapped one locally i had enhancements enabled so the tests were passing, but in CI it was failing as it did not have enhancements enabled
- Loading branch information
Showing
18 changed files
with
395 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
enterprise/backend/src/metabase_enterprise/search/scoring.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(ns metabase-enterprise.search.scoring | ||
(:require [metabase-enterprise.enhancements.ee-strategy-impl :as ee-strategy-impl] | ||
[metabase.public-settings.metastore :as settings.metastore] | ||
[metabase.search.scoring :as scoring])) | ||
|
||
(defn- official-collection-score | ||
"A scorer for items in official collections" | ||
[{:keys [collection_authority_level]}] | ||
(if (contains? #{"official"} collection_authority_level) | ||
1 | ||
0)) | ||
|
||
(def scoring-impl | ||
"Scoring implementation that adds score for items in official collections." | ||
(reify scoring/ResultScore | ||
(score-result [_ result] | ||
(conj (scoring/score-result scoring/oss-score-impl result) | ||
{:weight 2 | ||
:score (official-collection-score result) | ||
:name "official collection score"})))) | ||
|
||
(def ee-scoring | ||
"Enterprise scoring of results, falling back to the open source version if enterprise is not enabled." | ||
(ee-strategy-impl/reify-ee-strategy-impl #'settings.metastore/enable-enhancements? | ||
scoring-impl scoring/oss-score-impl | ||
scoring/ResultScore)) |
23 changes: 23 additions & 0 deletions
23
enterprise/backend/test/metabase_enterprise/search/scoring_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(ns metabase-enterprise.search.scoring-test | ||
(:require [clojure.test :refer :all] | ||
[metabase-enterprise.search.scoring :as ee-scoring] | ||
[metabase.search.scoring :as scoring])) | ||
|
||
(deftest official-collection-tests | ||
(testing "it should bump up the value of items in official collections" | ||
;; using the ee implementation that isn't wrapped by enable-enhancements? check | ||
(let [score (comp :score (partial scoring/score-and-result ee-scoring/scoring-impl "")) | ||
items [{:name "needle" | ||
:dashboardcard_count 0 | ||
:model "card"} | ||
{:name "foo" | ||
:model "dashboard"} | ||
{:name "foo2" | ||
:model "pulse"}]] | ||
(doseq [item items] | ||
(is (> (score (assoc item :collection_authority_level "official")) (score item)) | ||
(str "Item not greater for model: " (:model item)))) | ||
(doseq [item items] | ||
(is (= (score item) | ||
((comp :score (partial scoring/score-and-result scoring/oss-score-impl "")) | ||
item))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.