summaryrefslogtreecommitdiff
path: root/awk/stats_reviews.awk
diff options
context:
space:
mode:
authorLeon Rische <leon.rische@me.com>2020-01-11 15:24:56 +0100
committerLeon Rische <leon.rische@me.com>2020-01-11 15:24:56 +0100
commit1c7838eb972ac365e648fc231620cb5f18a07788 (patch)
treed0a339cec50b9ecb468f2c7d380e3d3c37e85927 /awk/stats_reviews.awk
Initial commit
Diffstat (limited to 'awk/stats_reviews.awk')
-rw-r--r--awk/stats_reviews.awk53
1 files changed, 53 insertions, 0 deletions
diff --git a/awk/stats_reviews.awk b/awk/stats_reviews.awk
new file mode 100644
index 0000000..bacafb2
--- /dev/null
+++ b/awk/stats_reviews.awk
@@ -0,0 +1,53 @@
+BEGIN {
+ FS="\t"
+ t_day = time_days_ago(1);
+ t_week = time_days_ago(7);
+ t_month = time_days_ago(30);
+}
+
+{
+ date = $1;
+ file = $2;
+ id = $3;
+ position = $4;
+ ease = $5;
+ box = $6;
+ interval = $7;
+ rating = $8;
+
+ if (box >= 2) {
+ if (date > t_day) {
+ ratings_day[rating]++;
+ n_day++;
+ }
+
+ if (date > t_week) {
+ ratings_week[rating]++;
+ n_week++;
+ }
+
+ if (date > t_month) {
+ ratings_month[rating]++;
+ n_month++;
+ }
+
+ ratings_all[rating]++;
+ n_all++;
+ }
+}
+
+END {
+ report(ratings_all, n_all);
+ report(ratings_month, n_month);
+ report(ratings_week, n_week);
+ report(ratings_day, n_day);
+}
+
+function report(values, n) {
+ if (n == 0) {
+ print 0 "\t" 0 "\t" 0 "\t" 0 "\t" 0;
+ } else {
+ print n "\t" values["again"] / n "\t" values["hard"] / n "\t" values["good"] /n "\t" values["easy"] / n;
+
+ }
+}