threatgrid / asami

A graph store for Clojure and ClojureScript
Eclipse Public License 1.0
637 stars 29 forks source link

Variable functions not being recognized #104

Closed quoll closed 3 years ago

quoll commented 3 years ago

Passing a function as a variable to a query is not being recognized.

Part of the stack trace is shown here:

  5 1. Unhandled clojure.lang.ExceptionInfo
  6    Unable to resolve symbol '?after in clojure.core
  7    {:op ?after, :namespace "clojure.core"}
  8                  util.cljc:   53  zuko.util$fn_for/invokeStatic
  9                  util.cljc:   49  zuko.util$fn_for/invoke
 10                 query.cljc:  194  asami.query$fn__9140$filter_join__9145$fn__9159/invoke
 11                 query.cljc:  176  asami.query$fn__9140$filter_join__9145/invoke
 12                 query.cljc:  352  asami.query$left_join/invokeStatic
 13                 query.cljc:  344  asami.query$left_join/invoke
 14                 query.cljc:  252  asami.query$fn__9270$minus__9275$fn__9289$ljoin__9296/invoke

This came about from the following code:

  (ns iroh-engine.engine.task.filter-undeliberated
    "When given an input containing a list of observables,
    return the subset of them that are missing recent verdicts."
    (:require [asami.query]
              [iroh-engine.lib.asami :as asami]
              [iroh-engine.lib.time :as time]))

  (defn find-undeliberated-observables [db-uri observables staleness-threshold]
    ;; find any observables that do not have a verdict more recent than max-age-seconds
    (mapv
     (partial asami/ref->entity db-uri)
     (asami/q '[:find [?obs ...]
                :in $ ?after ?staleness-threshold [[?type ?value]]
                :where
                [?obs :type ?type]
                [?obs :value ?value]
                (not [?verdict :type "verdict"]
                     [?verdict :observable ?obs]
                     [?action :verdicts ?verdict]
                     [?action :created ?time]
                     [(?after ?time ?staleness-threshold)])]
              db-uri
              time/after?
              staleness-threshold
              (mapv (juxt :type :value) observables))))
quoll commented 3 years ago

Fixed in 1.2.7