fixes invoice import issues, fixes issue with too many keys in s3 for general produce.
This commit is contained in:
@@ -225,10 +225,27 @@
|
||||
:destination-key invoice-key })
|
||||
invoice-key))
|
||||
|
||||
(defn get-all-keys
|
||||
([]
|
||||
(let [first-page-result (s3/list-objects-v2 {:bucket-name bucket-name
|
||||
:prefix "ntg-invoices/pending"})]
|
||||
(lazy-seq (concat (:object-summaries first-page-result) (get-all-keys (:next-continuation-token first-page-result))))))
|
||||
([next-token ]
|
||||
(when next-token
|
||||
(let [page-result (s3/list-objects-v2 {:bucket-name bucket-name
|
||||
:prefix "ntg-invoices/pending"
|
||||
:continuation-token next-token})]
|
||||
(println "getting next page " next-token)
|
||||
(when (seq (:object-summaries page-result))
|
||||
(lazy-seq (concat (:object-summaries page-result) (get-all-keys (:next-continuation-token page-result)))))))))
|
||||
|
||||
(defn recent? [k]
|
||||
(time/after? (:last-modified k) (time/plus (time/now) (time/days -15)))
|
||||
)
|
||||
|
||||
(defn import-ntg-invoices
|
||||
([] (import-ntg-invoices (->> (s3/list-objects-v2 {:bucket-name bucket-name
|
||||
:prefix "ntg-invoices/pending"})
|
||||
:object-summaries
|
||||
([] (import-ntg-invoices (->> (get-all-keys)
|
||||
(filter recent?)
|
||||
(map :key))))
|
||||
([keys]
|
||||
(let [clients (map first (d/q '[:find (pull ?c [:client/code
|
||||
|
||||
Reference in New Issue
Block a user