Skip to content

Commit

Permalink
Don't filter spam if the attrs changed (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwwoelfel authored Dec 18, 2024
1 parent dc003ef commit af954ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 5 additions & 2 deletions server/src/instant/db/model/attr.clj
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@
(seekById [this id])
(seekByFwdIdentName [this fwd-ident])
(seekByRevIdentName [this revIdent])
(attrIdsForEtype [this etype]))
(attrIdsForEtype [this etype])
(unwrap [this]))

;; Creates a wrapper over attrs. Makes them act like a regular list, but
;; we can also index them on demand so that our access patterns will be
Expand Down Expand Up @@ -570,7 +571,9 @@
(attrIdsForEtype [_this etype]
(-> @cache
:ids-by-etype
(get etype #{}))))
(get etype #{})))
(unwrap [_this]
elements))

(defn wrap-attrs [attrs]
(Attrs. attrs (delay (index-attrs attrs))))
Expand Down
9 changes: 4 additions & 5 deletions server/src/instant/reactive/query.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
[instant.jdbc.aurora :as aurora]
[instant.reactive.store :as rs]
[instant.util.instaql :refer [instaql-nodes->object-tree]]
[instant.util.tracer :as tracer])
(:import
(org.apache.commons.codec.digest DigestUtils)))
[instant.util.tracer :as tracer]))

(defn- datalog-query-cached!
"Returns the result of a datalog query. Leverages atom and
Expand Down Expand Up @@ -95,7 +93,7 @@
(defn instaql-query-reactive!
"Returns the result of an instaql query while producing book-keeping side
effects in the store. To be used with session"
[store-conn {:keys [session-id app-id] :as base-ctx} instaql-query return-type]
[store-conn {:keys [session-id app-id attrs] :as base-ctx} instaql-query return-type]
(tracer/with-span! {:name "instaql-query-reactive!"
:attributes {:session-id session-id
:app-id app-id
Expand All @@ -112,7 +110,8 @@
:record-datalog-query-finish! (partial rs/record-datalog-query-finish! store-conn ctx))))))

instaql-result (iq/permissioned-query ctx instaql-query)
result-hash (DigestUtils/md5Hex (pr-str instaql-result))
result-hash (hash {:instaql-result instaql-result
:attrs (attr-model/unwrap attrs)})
{:keys [result-changed?]} (rs/add-instaql-query! store-conn ctx result-hash)]
{:instaql-result (case return-type
:join-rows (collect-instaql-results-for-client instaql-result)
Expand Down
2 changes: 1 addition & 1 deletion server/src/instant/reactive/store.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
:db/index true}
:instaql-query/stale? {:db/type :db.type/boolean}
:instaql-query/version {:db/type :db.type/integer}
:instaql-query/hash {:db/type :db.type/string}
:instaql-query/hash {:db/type :db.type/number}
;; This would be easier if we had a store per app
:instaql-query/session-id+query
{:db/tupleAttrs [:instaql-query/session-id :instaql-query/query]
Expand Down

0 comments on commit af954ae

Please sign in to comment.