-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·78 lines (63 loc) · 1.92 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
export_file="WCA_export.tsv.zip"
export_folder="WCA_export"
ordered_file="WCA_export/WCA_export_Results_Ordered.tsv"
download=false
# First we check if the file exists.
if [ -f $export_file ]; then
one_week=$(date -d 'now - 7 days' +%s) # export older than 1 week is suggested to be replaced
date_of_export=$(date -r "$export_file" +%s)
if (( date_of_export <= one_week )); then # Here we check how old the export is.
echo "$export_file is older than 7 days."
echo "Cleaning old data."
rm $export_file;
download=true;
if [ -d "$export_folder" ]; then
rm -rR "$export_folder"
fi
else
echo "$export_file is up to date."
fi
else
download=true;
fi
if [ "$download" = true ]; then
echo "Downloading the latest export."
wget -q https://www.worldcubeassociation.org/results/misc/WCA_export.tsv.zip
fi
if [ ! -f $export_file ]; then
echo "There was an error while downloading.";
exit;
else
order=false;
if [ ! -d "$export_folder" ] || [ "$download" = true ]; then
echo "Extracting $export_file"
unzip "$export_file" -d "$export_folder"
order=true;
fi
if [ ! -f "$ordered_file" ] || [ "$order" = true ]; then
echo "Sorting results..."
python3 src/create_sorted_tsv_with_date.py
fi
# delete possible existing pages
if [ -d pages ]; then
for f in $(ls pages); do
rm pages/$f
done
else
mkdir pages
fi
cp img/favicon.ico pages/favicon.ico
cp img/cover.png pages/cover.png
echo "Running setup"
python3 setup.py
echo "Computing statistics..."
for f in $(ls src |grep stat*); do
echo $f
python3 src/$f page=true
done
echo "Computing done."
python3 src/index.py
python3 src/about.py
echo "Open pages/index.html for a complete view."
fi