|
@@ -149,7 +149,9 @@
|
|
|
collect entity)
|
|
collect entity)
|
|
|
#'<
|
|
#'<
|
|
|
:key #'(lambda (i) (parse-integer (getf i :datetime)))))
|
|
:key #'(lambda (i) (parse-integer (getf i :datetime)))))
|
|
|
- (balances (make-hash-table :size (hash-table-count (gethash "account" db)))))
|
|
|
|
|
|
|
+ (balances (make-hash-table :size (hash-table-count (gethash "account" db))))
|
|
|
|
|
+ (existing-docs (docs (db.find "events" ($ "type" "finance")
|
|
|
|
|
+ :limit (floor (* 1.1 (length transactions)))))))
|
|
|
(format t "Got ~A with ~A transactions~%" filename (length transactions))
|
|
(format t "Got ~A with ~A transactions~%" filename (length transactions))
|
|
|
(dolist (entity transactions)
|
|
(dolist (entity transactions)
|
|
|
(destructuring-bind (&key from-account-id from-amount
|
|
(destructuring-bind (&key from-account-id from-amount
|
|
@@ -160,14 +162,14 @@
|
|
|
(when (not (string= to-account-id "0"))
|
|
(when (not (string= to-account-id "0"))
|
|
|
(incf (gethash (parse-integer to-account-id) balances 0) (parse-integer to-amount)))
|
|
(incf (gethash (parse-integer to-account-id) balances 0) (parse-integer to-amount)))
|
|
|
(let* ((new-doc (make-finance-doc entity db balances))
|
|
(let* ((new-doc (make-finance-doc entity db balances))
|
|
|
- (existing-doc (first (docs (db.find "events"
|
|
|
|
|
- (kv ($ "type" "finance")
|
|
|
|
|
- ($ "financisto.id" (parse-integer -id)))))))
|
|
|
|
|
|
|
+ (existing-doc (find (parse-integer -id)
|
|
|
|
|
+ existing-docs
|
|
|
|
|
+ :key (lambda (d) (get-element "financisto.id" d))))
|
|
|
(new-ts (parse-integer datetime)))
|
|
(new-ts (parse-integer datetime)))
|
|
|
(cl-mongo::kv-container-add
|
|
(cl-mongo::kv-container-add
|
|
|
(kv "loc"
|
|
(kv "loc"
|
|
|
- (if (and existing-doc (= new-ts (cl-mongo::raw
|
|
|
|
|
- (get-element "ts" existing-doc))))
|
|
|
|
|
|
|
+ (if (and existing-doc
|
|
|
|
|
+ (= new-ts (cl-mongo::raw (get-element "ts" existing-doc))))
|
|
|
(get-element "loc" existing-doc)
|
|
(get-element "loc" existing-doc)
|
|
|
(timeliner.locations:point->doc
|
|
(timeliner.locations:point->doc
|
|
|
(timeliner.locations:find-location-at new-ts))))
|
|
(timeliner.locations:find-location-at new-ts))))
|