update gemstats.fish

This commit is contained in:
exquisitecorp 2021-07-17 04:08:50 -05:00
parent ada18a8128
commit 0d97a9ea8f
1 changed files with 12 additions and 16 deletions

View File

@ -1,15 +1,5 @@
#!/usr/bin/env fish
###########################################
# #
# gemstats by #
# exquisitecorp #
# #
# public domain #
# 2021 #
# #
###########################################
set access_log ~/code/gemstats/temp.log
cat "/home/gemini/access.log" > $access_log
@ -38,18 +28,24 @@ set total_days_prev_month $month_days[$pmonth]
# loop through days of prev month starting on same day of month
for day_counter in (seq $day $total_days_prev_month)
set subtotal (grep $USER $access_log | grep (date --date=$pyear-$pmonth-$day_counter +"%Y-%m-%d" ) | wc -l)
set user_subtotal (grep $USER $access_log | grep (date --date=$pyear-$pmonth-$day_counter +"%Y-%m-%d" ) | wc -l)
set entire_subtotal (grep (date --date=$pyear-$pmonth-$day_counter +"%Y-%m-%d" ) $access_log | wc -l)
end
# check access log for current month
# easier since we don't need to weed out people viewing the gemlog AFTER our date (unless there is time travel)
set subtotal2 (grep $USER $access_log | grep (date +"%m") | wc -l)
set user_subtotal2 (grep $USER $access_log | grep (date +"%m") | wc -l)
set entire_subtotal2 ( grep (date +"%m") $access_log | wc -l)
echo "Gemlog stats for ~$USER"
echo "Gemlog stats for Ctrl-C Club"
echo "Views today: " ( grep (date +"%Y-%m-%d") $access_log | wc -l )
echo "Views past month: " (math $entire_subtotal + $entire_subtotal2)
echo "Views for all time: " (cat $access_log | wc -l) # just the total number of lines of the log
echo -e "\nGemlog stats for ~$USER"
echo "Views today: " (grep $USER $access_log | grep (date +"%Y-%m-%d") | wc -l)
echo "Views past month: " (math $subtotal + $subtotal2)
# removing my own IP address
echo "Views for all time: " (grep $USER $access_log | grep -v "69.120.239.191" | wc -l)
echo "Views past month: " (math $user_subtotal + $user_subtotal2)
echo "Views for all time: " (grep $USER $access_log | wc -l)
rm $access_log