summaryrefslogtreecommitdiff
path: root/awk/stats_positions.awk
blob: 735013ae04acb1c5b6d3d383b84807c3eb4b0daf (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
BEGIN {
    FS="\t";
    total = 0;
    suspended = 0;
    ease = 0;
    interval = 0;
    box = 0;
    due = 0;
    now = strftime("%FT%TZ", systime(), 1);
    n_stats = 0;
}

{
    total += 1;

    type = $3;
    by_type[type] += 1;

    # Don't collect ease / box / interval stats for suspended cards
    if ($4 == "1") {
        suspended += 1;
    } else {
        ease += $6;
        box += $7;
        interval += $8;
        n_stats++;
    }


    if ($4 == "0" && $9 < now) {
        due += 1;
    }
}

END {
    print "total" "\t" total;
    print "suspended" "\t" suspended;
    print "due" "\t" due;
    for (var in by_type) {
        print "type-" var "\t" by_type[var];
    }

    if (n_stats > 0) {
        print "avg-ease" "\t" ease / n_stats;
        print "avg-box" "\t" box / n_stats;
        print "avg-interval" "\t" interval / n_stats;
    } else {
        print "avg-ease" "\t" 0.0;
        print "avg-box" "\t" 0;
        print "avg-interval" "\t" 0.0;
    }
}