summaryrefslogtreecommitdiff
path: root/awk/stats_cards.awk
blob: 31a00474bbc5c14857d759007eaa5e1c3a9e1ece (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
BEGIN {
    FS="\t";
    total = 0;
    n_suspended = 0;

    t_day = time_days_ago(1);
    t_week = time_days_ago(7);
    t_month = time_days_ago(30);

    created["day"] = 0;
    created["week"] = 0;
    created["month"] = 0;
}

{
    total += 1;

    type = $3;
    by_type[type] += 1;
    suspended = $4 == "1";

    if (suspended) {
        n_suspended++;
    } else {
        if ($5 > t_day) {
            created["day"]++;
        }

        if ($5 > t_week) {
            created["week"]++;
        }

        if ($5 > t_month) {
            created["month"]++;
        }
    }
}

END {
    print "("
    print "  :total " total;
    print "  :suspended " n_suspended;
    print "  :created-day " created["day"];
    print "  :created-week " created["week"];
    print "  :created-month " created["month"];
    for (var in by_type) {
        print "  :type-" var " " by_type[var];
    }
    print ")"
}