109 lines
2.4 KiB
Bash
109 lines
2.4 KiB
Bash
#!/bin/bash
|
|
|
|
get_next_level() {
|
|
local level
|
|
next=()
|
|
for (( level = curlevel + 1; level <= 16; level++))
|
|
do
|
|
if (( lvl[level] > last["AP"] ))
|
|
then
|
|
next+=(
|
|
CDEF:nextcross$level=pred,${lvl[level]},GE,pred,UNKN,IF
|
|
VDEF:nexttime$level=nextcross$level,FIRST
|
|
"PRINT:nexttime$level:$level %s:strftime"
|
|
)
|
|
fi
|
|
done
|
|
{
|
|
read
|
|
while read level timestamp
|
|
do
|
|
nextlevels[level]=$timestamp
|
|
done
|
|
} < <(
|
|
rrdtool graph /dev/null -s ${first["time"]%:} -e +15y \
|
|
DEF:data=$rrdfile:AP:AVERAGE:step=600 \
|
|
VDEF:intercept=data,LSLINT \
|
|
VDEF:growth=data,LSLSLOPE \
|
|
CDEF:trend=data,POP,COUNT,growth,*,intercept,+ \
|
|
CDEF:pred=TIME,NOW,GE,trend,UNKN,IF \
|
|
"${next[@]}"
|
|
)
|
|
|
|
for stat in ${medals[@]}
|
|
do
|
|
next=()
|
|
if ! (( hasbronze[$stat] ))
|
|
then
|
|
next+=(
|
|
CDEF:nextcrossbronze=pred,${bronze[$stat]},GE,pred,UNKN,IF
|
|
VDEF:nexttimebronze=nextcrossbronze,FIRST
|
|
"PRINT:nexttimebronze:bronze %s:strftime"
|
|
)
|
|
fi
|
|
if ! (( hassilver[$stat] ))
|
|
then
|
|
next+=(
|
|
CDEF:nextcrosssilver=pred,${silver[$stat]},GE,pred,UNKN,IF
|
|
VDEF:nexttimesilver=nextcrosssilver,FIRST
|
|
"PRINT:nexttimesilver:silver %s:strftime"
|
|
)
|
|
fi
|
|
if ! (( hasgold[$stat] ))
|
|
then
|
|
next+=(
|
|
CDEF:nextcrossgold=pred,${gold[$stat]},GE,pred,UNKN,IF
|
|
VDEF:nexttimegold=nextcrossgold,FIRST
|
|
"PRINT:nexttimegold:gold %s:strftime"
|
|
)
|
|
fi
|
|
if ! (( hasplatinum[$stat] ))
|
|
then
|
|
next+=(
|
|
CDEF:nextcrossplatinum=pred,${platinum[$stat]},GE,pred,UNKN,IF
|
|
VDEF:nexttimeplatinum=nextcrossplatinum,FIRST
|
|
"PRINT:nexttimeplatinum:platinum %s:strftime"
|
|
)
|
|
fi
|
|
if ! (( hasblack[$stat] ))
|
|
then
|
|
next+=(
|
|
CDEF:nextcrossblack=pred,${black[$stat]},GE,pred,UNKN,IF
|
|
VDEF:nexttimeblack=nextcrossblack,FIRST
|
|
"PRINT:nexttimeblack:black %s:strftime"
|
|
)
|
|
fi
|
|
{
|
|
read
|
|
while read matter timestamp
|
|
do
|
|
case $matter in
|
|
bronze)
|
|
nextbronze[timestamp]+="$stat "
|
|
;;
|
|
silver)
|
|
nextsilver[timestamp]+="$stat "
|
|
;;
|
|
gold)
|
|
nextgold[timestamp]+="$stat "
|
|
;;
|
|
platinum)
|
|
nextplatinum[timestamp]+="$stat "
|
|
;;
|
|
black)
|
|
nextblack[timestamp]+="$stat "
|
|
;;
|
|
esac
|
|
done
|
|
} < <(
|
|
rrdtool graph /dev/null -s ${first["time"]%:} -e +15y \
|
|
DEF:data=$rrdfile:$stat:AVERAGE:step=600 \
|
|
VDEF:intercept=data,LSLINT \
|
|
VDEF:growth=data,LSLSLOPE \
|
|
CDEF:trend=data,POP,COUNT,growth,*,intercept,+ \
|
|
CDEF:pred=TIME,NOW,GE,trend,UNKN,IF \
|
|
"${next[@]}"
|
|
)
|
|
done
|
|
}
|