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

    if ($4 == "1") {
        suspended++;
    }

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

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

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

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