Skip to content
Snippets Groups Projects
Unverified Commit 534951b7 authored by bryan's avatar bryan Committed by GitHub
Browse files

parallelize coll perm graph group lookup (#45256)

* parallelize coll perm graph group lookup w/ core.async

* respond to code review

* add + uses ExecutorCompletionService map function

* rename test

* more tests

* no concurrency for cljs

* fix timeout + add more tests

* use claypoole

* cleanup

* add kondo hooks for claypoole

* cleanup

* Can't use libraries that don't have a license

Revert "add kondo hooks for claypoole"

This reverts commit 9d93b55b28d69267b65260f2b046420d67604361.

* ignore unused value

-- TODO: check back in on claypoole to see if the kondo config gets merged

* fix linter
parent 676b48f1
Branches
Tags
No related merge requests found
......@@ -127,6 +127,7 @@
org.apache.xmlgraphics/batik-all {:mvn/version "1.17"} ; SVG -> image
org.bouncycastle/bcpkix-jdk18on {:mvn/version "1.78"} ; Bouncy Castle crypto library -- explicit version of BC specified to resolve illegal reflective access errors
org.bouncycastle/bcprov-jdk18on {:mvn/version "1.78"}
org.clj-commons/claypoole {:mvn/version "1.2.2"} ; Threadpool tools for Clojure
org.clj-commons/hickory {:mvn/version "0.7.4" ; Parse HTML into Clojure data structures
:exclusions [org.jsoup/jsoup]}
org.clojars.pntblnk/clj-ldap {:mvn/version "0.0.17"} ; LDAP client
......@@ -180,7 +181,8 @@
slingshot/slingshot {:mvn/version "0.12.2"} ; enhanced throw/catch, used by other deps
stencil/stencil {:mvn/version "0.5.0"} ; Mustache templates for Clojure
user-agent/user-agent {:mvn/version "0.1.1"} ; User-Agent string parser, for Login History page & elsewhere
weavejester/dependency {:mvn/version "0.2.1"}} ; Dependency graphs and topological sorting
weavejester/dependency {:mvn/version "0.2.1"} ; Dependency graphs and topological sorting
}
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
......
......@@ -3,6 +3,7 @@
details and for the code for generating and updating the *data* permissions graph."
(:require
[clojure.data :as data]
[com.climate.claypoole :as cp]
[metabase.api.common :as api]
[metabase.audit :as audit]
[metabase.db.query :as mdb.query]
......@@ -78,16 +79,23 @@
[:not [:like :location (h2x/literal (format "/%d/%%" collection-id))]]))}]
(set (map :id (mdb.query/query honeysql-form)))))
(defn- calculate-perm-groups [collection-namespace group-id->perms collection-ids]
(into {}
#_:clj-kondo/ignore
(cp/with-shutdown! [pool (+ 2 (cp/ncpus))]
(doall (cp/upmap pool
(fn [group-id]
[group-id
(group-permissions-graph collection-namespace (group-id->perms group-id) collection-ids)])
(t2/select-pks-set PermissionsGroup))))))
(defn- collection-permission-graph
"Return the permission graph for the collections with id in `collection-ids` and the root collection."
([collection-ids] (collection-permission-graph collection-ids nil))
([collection-ids collection-namespace]
(let [group-id->perms (group-id->permissions-set)]
{:revision (c-perm-revision/latest-id)
:groups (into {} (for [group-id (t2/select-pks-set PermissionsGroup)]
{group-id (group-permissions-graph collection-namespace
(group-id->perms group-id)
collection-ids)}))})))
:groups (calculate-perm-groups collection-namespace group-id->perms collection-ids)})))
(defn- modify-instance-analytics-for-admins
"In the graph, override the instance analytics collection within the admin group to read."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment