Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
Refactoring des queries
Browse files Browse the repository at this point in the history
A la lecture de la documentation sur les "find specifications", on trouve de meilleures systèmes que "map first" et
"ffirst" pour générer des résultats plus propres.

+ Fix de la pull query après lecture des "pull patterns"
  • Loading branch information
Charlynux committed Feb 19, 2022
1 parent 7bd5bcd commit e207d69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 6 additions & 0 deletions repl/introduce_datascript.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@
date)))
(sort-by :nb-jours <)
(clojure.pprint/print-table))

(d/q
'[:find (count ?b) .
:where
[?u :borrowings ?b]]
@conn)
22 changes: 10 additions & 12 deletions src/library_monkey/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,19 @@

(count (map first (d/q '[:find (pull ?r [:pseudo])
:where [?r :borrowings ?b]]
@conn)))
@conn))))

)
(defn read-aggregates [conn]
(hash-map
:count (ffirst
(d/q
'[:find (count ?b)
:where
[?u :borrowings ?b]]
@conn))
:reports (map first (d/q '[:find (pull ?r [:pseudo :username :borrowings])
:where [?r :borrowings ?b]]
@conn)))
)
:count (d/q
'[:find (count ?b) .
:where
[?u :borrowings ?b]]
@conn)
:reports (d/q '[:find [(pull ?r [:pseudo :username
{:borrowings [:titre :date-de-retour :type-de-document]}]) ...]
:where [?r :borrowings ?b]]
@conn)))

(def amiens-library
(reify Library
Expand Down

0 comments on commit e207d69

Please sign in to comment.