Add built-in property to list

Hide it on edit so query table doesn't look weird.
Also removed needless arity wrappings in block fns
This commit is contained in:
Gabriel Horner
2022-12-14 11:17:12 -05:00
committed by Tienson Qin
parent 199be34244
commit 39e1b8dc8a
3 changed files with 28 additions and 17 deletions

View File

@@ -41,31 +41,31 @@ and handles unexpected failure."
(gp-block/page-name->map original-page-name with-id? (db/get-db (state/get-current-repo)) with-timestamp? (state/get-date-formatter))))
(defn- normalize-as-percentage
([block]
(some->> block
str
(re-matches #"(-?\d+\.?\d*)%")
second
(#(/ % 100)))))
[block]
(some->> block
str
(re-matches #"(-?\d+\.?\d*)%")
second
(#(/ % 100))))
(defn- normalize-as-date
([block]
(some->> block
str
date/normalize-date
(tf/unparse date/custom-formatter))))
[block]
(some->> block
str
date/normalize-date
(tf/unparse date/custom-formatter)))
(defn normalize-block
"Normalizes supported formats such as dates and percentages.
Be careful, this function may harm query sort performance!
- nlp-date? - Enable NLP parsing on date items.
Requires heavy computation (see `normalize-as-date` for details)"
([block nlp-date?]
(->> [normalize-as-percentage (when nlp-date? normalize-as-date) identity]
(remove nil?)
(map #(% (if (set? block) (first block) block)))
(remove nil?)
(first))))
[block nlp-date?]
(->> [normalize-as-percentage (when nlp-date? normalize-as-date) identity]
(remove nil?)
(map #(% (if (set? block) (first block) block)))
(remove nil?)
(first)))
(defn parse-block
([block]