diff options
author | emkael <emkael@tlen.pl> | 2021-11-21 15:48:21 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2021-11-21 15:48:21 +0100 |
commit | 9c2f489be7af2c6198055effc07c4cdb6f3b9296 (patch) | |
tree | a50878c33d65fb30f302750d57ca4849dd6b512c | |
parent | ef154ba0c547fa32242643e2195f0f89a79e5859 (diff) |
Checking either 2021 or 2022 paid status
-rwxr-xr-x | dumps/check-paid.sh | 2 | ||||
-rwxr-xr-x | dumps/import-players.sh | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/dumps/check-paid.sh b/dumps/check-paid.sh index 3b864c8..a9be3d8 100755 --- a/dumps/check-paid.sh +++ b/dumps/check-paid.sh @@ -4,5 +4,5 @@ PLAYERSDB=${LIGA_PLAYERS_DB_NAME} ROUNDFROM=$2 ROUNDTO=$3 echo $DBNAME -QUERY="SELECT dmpplayers.link, CONCAT(dmpplayers.gname, ' ', dmpplayers.sname), teams.fullname, CONCAT(segments.rnd, '-', segments.segment) FROM $DBNAME.butler butler JOIN $DBNAME.players dmpplayers ON dmpplayers.id = butler.id JOIN $PLAYERSDB.players players ON players.id = dmpplayers.link JOIN $DBNAME.teams teams ON teams.id = dmpplayers.team JOIN (SELECT rnd, segment, openN as pl FROM $DBNAME.segments UNION SELECT rnd, segment, openE as pl FROM $DBNAME.segments UNION SELECT rnd, segment, openW as pl FROM $DBNAME.segments UNION SELECT rnd, segment, openS as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeN as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeE as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeW as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeS as pl FROM $DBNAME.segments) segments ON segments.pl = dmpplayers.id WHERE players.flag2 <> 'T' AND segments.rnd >= $ROUNDFROM AND segments.rnd <= $ROUNDTO ORDER BY dmpplayers.link, segments.rnd, segments.segment;" +QUERY="SELECT dmpplayers.link, CONCAT(dmpplayers.gname, ' ', dmpplayers.sname), teams.fullname, CONCAT(segments.rnd, '-', segments.segment) FROM $DBNAME.butler butler JOIN $DBNAME.players dmpplayers ON dmpplayers.id = butler.id JOIN $PLAYERSDB.players players ON players.id = dmpplayers.link JOIN $DBNAME.teams teams ON teams.id = dmpplayers.team JOIN (SELECT rnd, segment, openN as pl FROM $DBNAME.segments UNION SELECT rnd, segment, openE as pl FROM $DBNAME.segments UNION SELECT rnd, segment, openW as pl FROM $DBNAME.segments UNION SELECT rnd, segment, openS as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeN as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeE as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeW as pl FROM $DBNAME.segments UNION SELECT rnd, segment, closeS as pl FROM $DBNAME.segments) segments ON segments.pl = dmpplayers.id WHERE players.flag1 <> 'T' AND players.flag2 <> 'T' AND segments.rnd >= $ROUNDFROM AND segments.rnd <= $ROUNDTO ORDER BY dmpplayers.link, segments.rnd, segments.segment;" echo $QUERY | mysql ${LIGA_MYSQL_CONNECTION_OPTS} -N diff --git a/dumps/import-players.sh b/dumps/import-players.sh index 3edb7c7..8996812 100755 --- a/dumps/import-players.sh +++ b/dumps/import-players.sh @@ -1,14 +1,13 @@ #!/bin/bash cd $(dirname $0) DBNAME=${LIGA_PLAYERS_DB_NAME} -curl ${LIGA_BAZA_CSV} | iconv -f cp1250 -t utf8 | grep '^[0-9]' | sed 's/;[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/;T/g' | cut -d';' -f1-7,9,11 > baza.csv +curl ${LIGA_BAZA_CSV} | iconv -f cp1250 -t utf8 | grep '^[0-9]' | sed 's/;[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/;T/g' | cut -d';' -f1-5,7,9-11 > baza.csv mysql ${LIGA_MYSQL_CONNECTION_OPTS} --local-infile=1 $DBNAME -e "TRUNCATE players; LOAD DATA LOCAL INFILE 'baza.csv' REPLACE INTO TABLE players FIELDS TERMINATED BY ';' ENCLOSED BY '\"' -(ID, gname, sname, rank, loc1, flag1, loc2, flag2, info); +(ID, gname, sname, rank, loc1, loc2, flag1, flag2, info); UPDATE players SET age = REPLACE(flag1, 'K', ''), sex = IF(POSITION('K' IN flag1), 'K', ''); -UPDATE players SET flag1 = NULL; " rm baza.csv |