Skip to content

Commit

Permalink
enhance: also replace distinct-by in deps/graph-parser & electron/search
Browse files Browse the repository at this point in the history
  • Loading branch information
RCmerci committed Dec 26, 2022
1 parent fa0a032 commit db7975d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
15 changes: 8 additions & 7 deletions deps/graph-parser/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
{com.andrewmcveigh/cljs-time {:git/url "https://github.com/logseq/cljs-time" ;; fork
:sha "5704fbf48d3478eedcf24d458c8964b3c2fd59a9"}
;; local dep
logseq/db {:local/root "../db"}
logseq/db {:local/root "../db"}
;; stubbed in nbb
com.lambdaisland/glogi {:mvn/version "1.1.144"}
com.lambdaisland/glogi {:mvn/version "1.1.144"}
;; built in to nbb
cljs-bean/cljs-bean {:mvn/version "1.5.0"}}
cljs-bean/cljs-bean {:mvn/version "1.5.0"}
medley/medley {:mvn/version "1.4.0"}}

:aliases
;; This runs tests with nodejs. Would be nice to run this with in a browser env
;; since this is how its normally run in the app but this requires more setup
;; with karma, shadow-cljs.edn and headless mode on CI
{:test {:extra-paths ["test"]
:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}
org.clojure/clojurescript {:mvn/version "1.11.54"}}
:main-opts ["-m" "cljs-test-runner.main"]}
:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}
org.clojure/clojurescript {:mvn/version "1.11.54"}}
:main-opts ["-m" "cljs-test-runner.main"]}

:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.12.08"}}
:main-opts ["-m" "clj-kondo.main"]}}}
:main-opts ["-m" "clj-kondo.main"]}}}
10 changes: 2 additions & 8 deletions deps/graph-parser/src/logseq/graph_parser/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[clojure.edn :as edn]
[clojure.string :as string]
[clojure.walk :as walk]
[medley.core :as medley]
[logseq.graph-parser.log :as log]))

(defn safe-decode-uri-component
Expand Down Expand Up @@ -158,15 +159,8 @@
(string/join " ")))

(defn distinct-by
"Copy of frontend.util/distinct-by. Too basic to couple to main app"
[f col]
(reduce
(fn [acc x]
(if (some #(= (f x) (f %)) acc)
acc
(vec (conj acc x))))
[]
col))
(medley/distinct-by f (seq col)))

(defn normalize-format
[format]
Expand Down
11 changes: 3 additions & 8 deletions src/electron/electron/search.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
["better-sqlite3" :as sqlite3]
[clojure.string :as string]
["electron" :refer [app]]
[electron.logger :as logger]))
[electron.logger :as logger]
[medley.core :as medley]))

(defonce databases (atom nil))

Expand Down Expand Up @@ -240,13 +241,7 @@

(defn distinct-by
[f col]
(reduce
(fn [acc x]
(if (some #(= (f x) (f %)) acc)
acc
(vec (conj acc x))))
[]
col))
(medley/distinct-by f (seq col)))

(defn search-blocks
":page - the page to specificly search on"
Expand Down

0 comments on commit db7975d

Please sign in to comment.