removing old square

This commit is contained in:
2023-11-01 10:02:57 -07:00
parent 31dc514cdd
commit 3211635dce
13 changed files with 172 additions and 1250 deletions

View File

@@ -3,7 +3,6 @@
(:require
[auto-ap.datomic :refer [conn]]
[auto-ap.jobs.core :refer [execute]]
[auto-ap.square.core :as square]
[auto-ap.square.core3 :as square3]
[clj-time.coerce :as coerce]
[clj-time.core :as time]
@@ -12,42 +11,11 @@
[config.core :refer [env]]
[datomic.api :as dc]))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn historical-load-sales [client days]
(alog/info ::old-sales-loading)
(alog/info ::new-sales-loading :client (:client/code client) :days days)
(let [client (dc/pull (dc/db auto-ap.datomic/conn)
square/square-read
client)]
(doseq [square-location (:client/square-locations client)
:when (:square-location/client-location square-location)]
(println "orders")
(doseq [d (per/periodic-seq (time/plus (time/today) (time/days (- days)))
(time/today)
(time/days 1))]
(println d)
(square/upsert client square-location (coerce/to-date-time d) (coerce/to-date-time (time/plus d (time/days 1)))))
(println "refunds")
(square/upsert-refunds client square-location)
#_(with-redefs [square/lookup-dates (fn lookup-dates []
(->> (per/periodic-seq (time/plus (time/today) (time/days (- days)))
(time/today)
(time/days 2))
(map (fn [d]
[(atime/unparse (time/plus d (time/days 1)) atime/iso-date)
(atime/unparse (time/plus d (time/days 2)) atime/iso-date)]))))]
(square/upsert-settlements client square-location)))))
(defn historical-load-sales2 [client days]
(alog/info ::new-sales-loading)
(let [client (dc/pull (dc/db auto-ap.datomic/conn)
square/square-read
square3/square-read
client)
days (Long/parseLong days)]
(doseq [square-location (:client/square-locations client)
@@ -67,13 +35,8 @@
(defn load-historical-sales [args]
(let [{:keys [days client]} args
client (Long/parseLong client)
feature-flags (-> (dc/pull (dc/db conn) '[:client/feature-flags] client)
:client/feature-flags
set)]
(if (get feature-flags "new-square")
(historical-load-sales2 client days)
(historical-load-sales client days))))
client (Long/parseLong client)]
(historical-load-sales client days)))
(defn -main [& _]
(execute "load-historical-sales" #(load-historical-sales (:args env))))

View File

@@ -2,8 +2,8 @@
(:gen-class)
(:require
[auto-ap.jobs.core :refer [execute]]
[auto-ap.square.core :as square]))
[auto-ap.square.core3 :as square3]))
(defn -main [& _]
(execute "square-loading" square/upsert-all))
(execute "square-loading" square3/do-upsert-all))

View File

@@ -1,9 +0,0 @@
(ns auto-ap.jobs.square2
(:gen-class)
(:require
[auto-ap.jobs.core :refer [execute]]
[auto-ap.square.core3 :as square3]))
(defn -main [& _]
(execute "square3-loading" square3/do-upsert-all))