summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2021-05-29 17:30:41 +0200
committeremkael <emkael@tlen.pl>2021-05-29 17:30:41 +0200
commit9e7e12006de38f46c08d5bba28691837a4a6be8d (patch)
treef04d406e4a5c780c1b165a048a1373ad4f94746a
parent2eaee2fe846e27603af3df655837968cdf8e2c60 (diff)
Players data import from Cezar to Players db
-rw-r--r--Makefile3
-rwxr-xr-xdumps/import-players.sh13
2 files changed, 16 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 10748b9..e579a88 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,9 @@ pull:
autocommit: pull
@cd http && git diff --quiet || (date && git add . && git commit -m 'Autocommit' && GIT_SSH_COMMAND="ssh ${LIGA_SSH_OPTS}" git push -q)
+players: FORCE
+ ./dumps/import-players.sh
+
paid: players FORCE
./dumps/check-all-paid.sh
diff --git a/dumps/import-players.sh b/dumps/import-players.sh
new file mode 100755
index 0000000..5f499ef
--- /dev/null
+++ b/dumps/import-players.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+cd $(dirname $0)
+DBNAME=${LIGA_PLAYERS_DB_NAME}
+curl 'https://msc.com.pl/cezar/download/baza.csv' | grep '^[0-9]' > baza.csv
+mysql ${LIGA_MYSQL_CONNECTION_OPTS} --local-infile=1 $DBNAME -e "LOAD DATA LOCAL INFILE 'baza.csv'
+REPLACE
+INTO TABLE players
+FIELDS TERMINATED BY ';' ENCLOSED BY '\"'
+(ID, gname, sname, rank, loc1, info, loc2, flag1, flag2);
+UPDATE players SET age = REPLACE(info, 'K', ''), sex = IF(POSITION('K' IN info), 'K', '');
+UPDATE players SET info = NULL;
+"
+rm baza.csv