34 lines
719 B
Bash
34 lines
719 B
Bash
#!/bin/bash
|
|
|
|
echo " [client]
|
|
user=andregeissler_bikeparts
|
|
password=K01v1kk0!
|
|
host=vesta.agserver.de
|
|
database=andregeissler_bikeparts
|
|
" > mystat.conf
|
|
|
|
year=$1
|
|
if [ "$year" == "" ]
|
|
then
|
|
year=2023
|
|
fi
|
|
|
|
for months in `seq 12 -1 0`
|
|
do
|
|
month=$(printf "%02d" $months)
|
|
if [ "$month" == "00" ]
|
|
then
|
|
where="$year-%"
|
|
stat="$year"
|
|
else
|
|
where="$year-$month-%"
|
|
stat="$year-$month"
|
|
fi
|
|
|
|
query="select '$stat', ifnull(round(sum(a_distance)/1000,2),'') as km, ifnull(round(sum(a_duration)/3600,2),'') as std, ifnull(round(sum(a_hm),2),'') as hm from activities where a_date like '$where'";
|
|
PASS='K01v1kk0!'
|
|
echo "$query" | mysql --defaults-extra-file=mystat.conf -t
|
|
done
|
|
|
|
rm mystat.conf
|