clean up drops data

This commit is contained in:
2026-01-04 01:07:31 -05:00
parent 712361da86
commit 3f83ab9210
2 changed files with 18 additions and 1 deletions

View File

@@ -4,6 +4,15 @@
(defparameter *chronostory-drops-sheet-url* "https://docs.google.com/spreadsheets/d/e/2PACX-1vRpKuZGJQIFFxSi6kzYx4ALI0MQborpLEkh3J1qIGSd0Bw7U4NYg5CK-3ESzyK580z4D8NO59SUeC3k/pub?gid=1888753114&single=true&output=csv")
(defun cleanup-data (hm)
(dolist (key '("DropperID" "ItemID" "Chance" "MinQTY" "MaxQTY"))
(update-hash hm key (lambda (x) (string-replace-all "," x "")))
(update-hash hm key #'parse-integer))
(update-hash hm "AvgQty" #'parse-float)
(dolist (key '("isBoss" "Enable" "InGame"))
(update-hash hm key #'string->bool))
hm)
(defmethod refresh ((ds drop-data-source))
(let* ((data (drakma:http-request *chronostory-drops-sheet-url*))
(csv (cl-csv:read-csv data))
@@ -12,7 +21,8 @@
(keys (mapcar #'string-to-hash-table-key (subseq header 0 num-fields-to-keep)))
(drops (map 'vector
(lambda (row)
(pairhash keys (subseq row 0 num-fields-to-keep)))
(cleanup-data
(pairhash keys (subseq row 0 num-fields-to-keep) (dict))))
(cdr csv))))
(setf (cache ds) drops)
(write-string-into-file
@@ -23,4 +33,5 @@
(comment
(defvar drops (make-drop-data-source))
(refresh drops)
(reload drops))