From f8b76b6c2c73bb3e45424c2f01f80aee3a4c1ef0 Mon Sep 17 00:00:00 2001 From: Bryce Date: Fri, 29 Sep 2023 09:05:17 -0700 Subject: [PATCH] a variety of bug fixes. --- src/clj/auto_ap/graphql.clj | 6 +----- src/clj/auto_ap/graphql/yodlee2.clj | 14 ------------- src/clj/auto_ap/square/core3.clj | 10 +++++----- .../views/components/typeahead/vendor.cljs | 20 +++++++++++-------- .../auto_ap/views/pages/admin/accounts.cljs | 2 +- .../views/pages/admin/clients/form.cljs | 17 ++++++++-------- 6 files changed, 28 insertions(+), 41 deletions(-) delete mode 100644 src/clj/auto_ap/graphql/yodlee2.clj diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 7c1c3445..7f0498bd 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -20,7 +20,6 @@ [auto-ap.graphql.utils :refer [assert-admin attach-tracing-resolvers]] [auto-ap.graphql.vendors :as gq-vendors] [auto-ap.graphql.yodlee-merchants :as ym] - [auto-ap.graphql.yodlee2 :as gq-yodlee2] [auto-ap.logging :as alog :refer [error-event info-event warn-event]] [auto-ap.time :as time] [clj-time.coerce :as coerce] @@ -352,9 +351,7 @@ :cash_flow {:type :cash_flow_result :args {:client_id {:type :id}} :resolve :get-cash-flow} - :yodlee_provider_account_page {:type :yodlee_provider_account_page - :args {:client_id {:type :id}} - :resolve :get-yodlee-provider-account-page} + :account_page {:type :account_page :args {:name_like {:type 'String} @@ -794,7 +791,6 @@ (-> integreat-schema (attach-tracing-resolvers { - :get-yodlee-provider-account-page gq-yodlee2/get-yodlee-provider-account-page :get-accounts gq-accounts/get-graphql :get-all-accounts gq-accounts/get-all-graphql :get-transaction-rule-page gq-transaction-rules/get-transaction-rule-page diff --git a/src/clj/auto_ap/graphql/yodlee2.clj b/src/clj/auto_ap/graphql/yodlee2.clj deleted file mode 100644 index 933cb45e..00000000 --- a/src/clj/auto_ap/graphql/yodlee2.clj +++ /dev/null @@ -1,14 +0,0 @@ -(ns auto-ap.graphql.yodlee2 - (:require - [auto-ap.datomic.yodlee2 :as d-yodlee2] - [auto-ap.graphql.utils :refer [->graphql <-graphql]])) - -(defn get-yodlee-provider-account-page [context args _] - (let [args (assoc args :id (:id context)) - [yodlee-provider-accounts cnt] (d-yodlee2/get-graphql (<-graphql (assoc args :clients (:clients context))))] - {:yodlee_provider_accounts (map ->graphql yodlee-provider-accounts) - :total cnt - :count (count yodlee-provider-accounts) - :start (:start args 0) - :end (+ (:start args 0) (count yodlee-provider-accounts))})) - diff --git a/src/clj/auto_ap/square/core3.clj b/src/clj/auto_ap/square/core3.clj index 4f6cb956..d9c1e916 100644 --- a/src/clj/auto_ap/square/core3.clj +++ b/src/clj/auto_ap/square/core3.clj @@ -34,7 +34,7 @@ (def manifold-api-stream (let [stream (s/stream 100)] (->> stream - (s/throttle 80) + (s/throttle 50) (s/map (fn [[request attempt response-deferred]] (de/catch (de/chain @@ -47,8 +47,8 @@ :background-job "Square 3") (try (client/request (assoc request - :socket-timeout 5000 - :connection-timeout 5000 + :socket-timeout 10000 + :connection-timeout 10000 #_#_:connection-request-timeout 5000 :as :json)) (catch Throwable e @@ -60,7 +60,7 @@ (if (>= attempt 5) (throw e) (de/chain - (mt/in 1000 (fn [] 1)) + (mt/in 10000 (fn [] 1)) (fn [_] (de/recur (inc attempt))))))) (de/chain identity))) (fn [result] @@ -383,7 +383,7 @@ (daily-results client location (time/plus (time/now) (time/days -7)) (time/now))) ([client location start end] (capture-context->lc - (-> + (-> (de/chain (search client location start end) (fn [search-results] (->> (or search-results []) diff --git a/src/cljs/auto_ap/views/components/typeahead/vendor.cljs b/src/cljs/auto_ap/views/components/typeahead/vendor.cljs index a3b23064..e1cf6c47 100644 --- a/src/cljs/auto_ap/views/components/typeahead/vendor.cljs +++ b/src/cljs/auto_ap/views/components/typeahead/vendor.cljs @@ -46,15 +46,19 @@ ::input-value-settled [with-user] (fn [{:keys [user]} [_ input-value search-query set-items set-loading-status]] - (when (> (count input-value) 2) - (set-loading-status :loading) + (if (re-matches #"[a-zA-Z0-9\s\-]+" input-value) + (when (> (count input-value) 2) + (set-loading-status :loading) - - {:graphql {:token user - :query-obj {:venia/queries [{:query/data (search-query input-value ) - :query/alias :search-results}]} - :on-success [::search-completed set-items set-loading-status] - :on-error [::search-failed set-loading-status]}}))) + + {:graphql {:token user + :query-obj {:venia/queries [{:query/data (search-query input-value ) + :query/alias :search-results}]} + :on-success [::search-completed set-items set-loading-status] + :on-error [::search-failed set-loading-status]}}) + (do + (set-loading-status nil) + {})))) ;; TODO: This avoids the use of inferred externs by using aget. You could just use the ^js tag though (defn state-reducer [^js/FakeStateObject state ^js/FakeActionsAndChanges actions-and-changes] diff --git a/src/cljs/auto_ap/views/pages/admin/accounts.cljs b/src/cljs/auto_ap/views/pages/admin/accounts.cljs index b4c0f7dc..d821b3ee 100644 --- a/src/cljs/auto_ap/views/pages/admin/accounts.cljs +++ b/src/cljs/auto_ap/views/pages/admin/accounts.cljs @@ -32,7 +32,7 @@ :start (:start params 0) :per-page (:per-page params) :name-like (:name-like params) - :numeric-code (some-> params :numeric-code not-empty js/parseInt)} + :numeric-code (some-> params :numeric-code not-empty js/parseInt (#(if (js/Number.isNaN %) nil %)))} [[:accounts default-read] :total :start diff --git a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs index 6e3c11c2..db624ee8 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs @@ -211,14 +211,15 @@ ::mounted [with-user (re-frame/inject-cofx ::inject/sub [::subs/route-params])] (fn [{:keys [user db] ::subs/keys [route-params]} _] - {:graphql {:token user - :query-obj {:venia/queries [[:admin-client - {:id (js/parseInt (:id route-params))} - (events/client-detail-query user)]]} - :on-success (fn [result] - [::received (:admin-client result)])} - :db (-> db - (forms/stop-form ::form))})) + (when-let [id (some-> (:id route-params) (js/parseInt ) (#(if (js/Number.isNaN %) nil %)))] + {:graphql {:token user + :query-obj {:venia/queries [[:admin-client + {:id id} + (events/client-detail-query user)]]} + :on-success (fn [result] + [::received (:admin-client result)])} + :db (-> db + (forms/stop-form ::form))}))) (re-frame/reg-event-db ::received