mirror of https://github.com/logseq/logseq
fix(query-function): convert num string to float
parent
b3931bedb1
commit
c2978785d9
|
@ -12,7 +12,9 @@
|
|||
[s]
|
||||
(try
|
||||
(sci/eval-string s {:bindings {'sum sum
|
||||
'average average}})
|
||||
'average average
|
||||
'parseFloat js/parseFloat
|
||||
'isNaN js/isNaN}})
|
||||
(catch js/Error e
|
||||
(println "Query: sci eval failed:")
|
||||
(js/console.error e))))
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
(let [vals (map #(get-in % [:block/properties f]) result)
|
||||
int? (some integer? vals)]
|
||||
`(~'fn [~'b]
|
||||
(~'let [~'result (~'get-in ~'b [:block/properties ~f])]
|
||||
(~'let [~'result-str (~'get-in ~'b [:block/properties ~f])
|
||||
~'result-num (~'parseFloat ~'result-str)
|
||||
~'result (if (~'isNaN ~'result-num) ~'result-str ~'result-num)]
|
||||
(~'or ~'result (~'when ~int? 0))))))
|
||||
|
||||
:else
|
||||
|
|
Loading…
Reference in New Issue