diff options
-rwxr-xr-x | bin/cezar-db-fetch.sh | 2 | ||||
-rwxr-xr-x | bin/rankings-csv-import.sh | 2 | ||||
-rwxr-xr-x | bin/rankings-tables-build.sh | 8 | ||||
-rw-r--r-- | docs/convert-to-baza2.csv.sql | 10 | ||||
-rw-r--r-- | scripts/pyranking/fetch.py | 4 | ||||
-rw-r--r-- | scripts/rankings-tables-compile.py | 6 | ||||
-rw-r--r-- | templates/menu-age-new.html | 8 | ||||
-rw-r--r-- | templates/menu-age-old.html | 6 | ||||
-rw-r--r-- | templates/ranking.html | 8 |
9 files changed, 39 insertions, 15 deletions
diff --git a/bin/cezar-db-fetch.sh b/bin/cezar-db-fetch.sh index 3af7357..cfbc8ab 100755 --- a/bin/cezar-db-fetch.sh +++ b/bin/cezar-db-fetch.sh @@ -3,7 +3,7 @@ PAGEDIR=`dirname $0` DATE=`date --date='yesterday' +%Y%m%d` OUTPUTFILE=`realpath $PAGEDIR/../data/cezar/$DATE.csv` TMPFILE=$PAGEDIR/temp -wget http://msc.com.pl/cezar/download/baza.csv -q -O - | iconv -f windows-1250 -t utf-8 > $TMPFILE +wget http://msc.com.pl/cezar/download/baza2.csv -q -O $TMPFILE if [ -s $TMPFILE ]; then tail -n +2 $TMPFILE | sort > $OUTPUTFILE echo "Downloaded Cezar CSV into $OUTPUTFILE" diff --git a/bin/rankings-csv-import.sh b/bin/rankings-csv-import.sh index 54ce6bc..9eddd82 100755 --- a/bin/rankings-csv-import.sh +++ b/bin/rankings-csv-import.sh @@ -7,7 +7,7 @@ REPLACE INTO TABLE temp_rankings FIELDS TERMINATED BY ','; INSERT INTO rankings ( - SELECT pid, \`date\`, place, score, region, flags, rank, club, 0 + SELECT pid, \`date\`, place, score, region, gender, flags, rank, club, 0 FROM temp_rankings JOIN players ON players.id = temp_rankings.pid diff --git a/bin/rankings-tables-build.sh b/bin/rankings-tables-build.sh index 0d85972..d3806a7 100755 --- a/bin/rankings-tables-build.sh +++ b/bin/rankings-tables-build.sh @@ -2,9 +2,9 @@ CONFIG=$1 DIR=$2 cat $CONFIG | - jq '.[] | .date, .url, .index, .name' | - xargs -n4 | - while read DATE URL INDEX NAME + jq '.[] | .date, .url, .index, .menu_age // "old", .name' | + xargs -n5 | + while read DATE URL INDEX AGEMENU NAME do - python scripts/rankings-tables-compile.py "$NAME" $INDEX $DIR/.menu.html $DATE > $DIR/$URL + python scripts/rankings-tables-compile.py "$NAME" $INDEX $DIR/.menu.html $DATE "$AGEMENU" > $DIR/$URL done diff --git a/docs/convert-to-baza2.csv.sql b/docs/convert-to-baza2.csv.sql new file mode 100644 index 0000000..c6a5f22 --- /dev/null +++ b/docs/convert-to-baza2.csv.sql @@ -0,0 +1,10 @@ +ALTER TABLE `players` + ADD COLUMN `gender` varchar(1) COLLATE utf8_unicode_520_ci NOT NULL + AFTER `region`; +UPDATE `players` SET `gender` = 'K', `flags` = SUBSTRING(`flags` FROM 2) WHERE flags LIKE 'K%'; +UPDATE `players` SET `gender` = 'M' WHERE gender = ''; +ALTER TABLE `rankings` + ADD COLUMN `gender` varchar(1) COLLATE utf8_unicode_520_ci NOT NULL + AFTER `region`; +UPDATE `rankings` SET `gender` = 'K', `flags` = SUBSTRING(`flags` FROM 2) WHERE flags LIKE 'K%'; +UPDATE `rankings` SET `gender` = 'M' WHERE gender = ''; diff --git a/scripts/pyranking/fetch.py b/scripts/pyranking/fetch.py index 67ab5a6..b157280 100644 --- a/scripts/pyranking/fetch.py +++ b/scripts/pyranking/fetch.py @@ -7,8 +7,8 @@ def fetch_ranking(date, assoc=False): CONCAT(players.name, " ", players.surname) player, rankings.rank, rankings.region, rankings.club, - REPLACE(rankings.flags, "K", "") age, - IF(rankings.flags LIKE 'K%', "K", "") gender, + rankings.flags age, + rankings.gender, rankings.score, rankings.hidden FROM rankings diff --git a/scripts/rankings-tables-compile.py b/scripts/rankings-tables-compile.py index 925404c..0270c54 100644 --- a/scripts/rankings-tables-compile.py +++ b/scripts/rankings-tables-compile.py @@ -21,6 +21,12 @@ style_href['href'] = '%s?%d' % ('_res/ranking.css', os.path.getmtime('http/_res/ rawlink = table.select('a#rawlink')[0] rawlink['href'] = '%s/%s.csv' % (rawlink['href'], ranking_date) +age_menu = sys.argv[5] +age_menu_file = file('templates/menu-age-%s.html' % (age_menu)) +age_menu_placeholder = table.select('div[data-menu="age"]')[0] +age_menu_placeholder.clear() +age_menu_placeholder.append(bs4(age_menu_file, 'html.parser')) + menu_file = file(sys.argv[3]) menu = table.select('div.static-menu')[0] menu.clear() diff --git a/templates/menu-age-new.html b/templates/menu-age-new.html new file mode 100644 index 0000000..a0d4eb7 --- /dev/null +++ b/templates/menu-age-new.html @@ -0,0 +1,8 @@ +<button type="button" class="btn btn-default" data-filter="age" data-value="M">M</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="JM">JM</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="JJ">JJ</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="JS">JS</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="">-</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="S">S</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="N">N</button> +<button type="button" class="btn btn-default" data-clear="age">wszyscy</button> diff --git a/templates/menu-age-old.html b/templates/menu-age-old.html new file mode 100644 index 0000000..95172db --- /dev/null +++ b/templates/menu-age-old.html @@ -0,0 +1,6 @@ +<button type="button" class="btn btn-default" data-filter="age" data-value="M">M</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="J">J</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="">-</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="S">S</button> +<button type="button" class="btn btn-default" data-filter="age" data-value="N">N</button> +<button type="button" class="btn btn-default" data-clear="age">wszyscy</button> diff --git a/templates/ranking.html b/templates/ranking.html index 77636f0..4364cb6 100644 --- a/templates/ranking.html +++ b/templates/ranking.html @@ -52,13 +52,7 @@ </div> <div class="input-group" role="group"> <div class="input-group-addon">Kat. wiekowa</div> - <div class="input-group-btn"> - <button type="button" class="btn btn-default" data-filter="age" data-value="M">M</button> - <button type="button" class="btn btn-default" data-filter="age" data-value="J">J</button> - <button type="button" class="btn btn-default" data-filter="age" data-value="">-</button> - <button type="button" class="btn btn-default" data-filter="age" data-value="S">S</button> - <button type="button" class="btn btn-default" data-filter="age" data-value="N">N</button> - <button type="button" class="btn btn-default" data-clear="age">wszyscy</button> + <div class="input-group-btn" data-menu="age"> </div> </div> <div class="input-group" role="group"> |