init
This commit is contained in:
33
stat.sh
Normal file
33
stat.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user