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
1 changed files with 14 additions and 2 deletions

16
cv
View File

@ -1,13 +1,14 @@
#!/bin/bash
w=10
dfmt="+%Y-%m-%d"
ex(){
echo -e "> ${*}"
$@
}
[ -z $date ] && date=$(date +"%Y-%m-%d")
[ -z $ydate ] && ydate=$(date -d yesterday +"%Y-%m-%d")
[ -z $date ] && date=$(date $dfmt)
[ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
title(){
local w=36
printf "║ %-${w}s ║\n" "${*}"
@ -90,6 +91,17 @@ result(){
frame down
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
title "Queried at: $date"
if [ ! -z "$country" ]