Allow stats to be queried after midnight

This commit is contained in:
Michael De Roover 2020-08-09 00:46:01 +02:00
parent c2f135ba7c
commit 9d8a5d64ca
Signed by: vim
GPG Key ID: 075496E232CE04CB

16
cv
View File

@ -1,13 +1,14 @@
#!/bin/bash #!/bin/bash
w=10 w=10
dfmt="+%Y-%m-%d"
ex(){ ex(){
echo -e "> ${*}" echo -e "> ${*}"
$@ $@
} }
[ -z $date ] && date=$(date +"%Y-%m-%d") [ -z $date ] && date=$(date $dfmt)
[ -z $ydate ] && ydate=$(date -d yesterday +"%Y-%m-%d") [ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
title(){ title(){
local w=36 local w=36
printf "║ %-${w}s ║\n" "${*}" printf "║ %-${w}s ║\n" "${*}"
@ -90,6 +91,17 @@ result(){
frame down frame down
fi fi
} }
# Main code starts here.
# Get yesterday's stats for queries after midnight.
# Not pretty but it works I guess...
if [ "$2" == "yesterday" ]
then
date=$(date -d yesterday $dfmt)
ydate=$(date -d "2 days ago" $dfmt)
fi
frame top frame top
title "Queried at: $date" title "Queried at: $date"
if [ ! -z "$country" ] if [ ! -z "$country" ]