Skip to content

Commit

Permalink
Implement the stateful query api fluree/q
Browse files Browse the repository at this point in the history
  • Loading branch information
JaceRockman committed Jul 25, 2024
1 parent bac78e3 commit c06c3f1
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/clj/fluree/db/query/api.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

#?(:clj (set! *warn-on-reflection* true))

(defn q
([ds-or-db query]
(fql/query ds-or-db query))
([ds-or-db fuel-tracker query]
(fql/query ds-or-db fuel-tracker query)))

(defn history
"Return a summary of the changes over time, optionally with the full commit
details included."
Expand All @@ -40,17 +46,10 @@
did (assoc :did did :issuer did)))

(defn db->policy-db
<<<<<<< HEAD:src/clj/fluree/db/query/api.cljc
[db context {:keys [did default-allow?] :as _opts}]
(go-try
(if did
(<? (perm/wrap-identity-policy db did default-allow? nil))
=======
[db context request-opts]
(go-try
(if-let [policy-identity (perm/parse-policy-identity request-opts context)]
(<? (perm/wrap-identity-policy db policy-identity false nil))
>>>>>>> 6a46027f (Move condense sparql-query and fql-query into query):src/clj/fluree/db/api/query.cljc
db)))

(defn db->time-travel-db
Expand Down Expand Up @@ -86,7 +85,7 @@
(let [start #?(:clj (System/nanoTime)
:cljs (util/current-time-millis))
fuel-tracker (fuel/tracker max-fuel)]
(try* (let [result (<? (fql/query ds fuel-tracker query))]
(try* (let [result (<? (q ds fuel-tracker query))]
{:status 200
:result result
:time (util/response-time-formatted start)
Expand Down Expand Up @@ -120,7 +119,7 @@
(<? (db->reasoned-db $ opts))]
(if (::util/track-fuel? opts)
(<? (track-query dataset (:max-fuel opts) final-query))
(<? (fql/query dataset final-query)))))))
(<? (q dataset final-query)))))))

(defn contextualize-ledger-400-error
[info-str e]
Expand Down Expand Up @@ -264,8 +263,8 @@
trimmed-query (update sanitized-query :opts dissoc :meta :max-fuel ::util/track-fuel?)
max-fuel (:max-fuel opts)]
(if (::util/track-fuel? opts)
(<? (track-query ds max-fuel trimmed-query))
(<? (fql/query ds trimmed-query))))
(<? (track-query ds max-fuel query**))
(<? (q ds query**))))
(throw (ex-info "Missing ledger specification in connection query"
{:status 400, :error :db/invalid-query}))))))

Expand Down

0 comments on commit c06c3f1

Please sign in to comment.