Libraryless. Click here for Pure Java version (5147L/33K/114K).
1 | !7 |
2 | |
3 | static DependentCache<S> imageCache = new(f makeChart_fresh, f unixDay); |
4 | |
5 | answer { |
6 | if "visitors chart" ret standardChart(); |
7 | |
8 | if (match("visitors chart *", s, m) || match("visitors chart * days", s, m)) |
9 | ret makeChart_fresh(m.psi(0)); |
10 | } |
11 | |
12 | html { |
13 | ret himg(skipToURL(standardChart())); |
14 | } |
15 | |
16 | // 7 days |
17 | static S standardChart() { |
18 | ret imageCache!; |
19 | } |
20 | |
21 | static S makeChart_fresh() { |
22 | ret makeChart_fresh(7); |
23 | } |
24 | |
25 | static S makeChart_fresh(int days) { |
26 | print("Making visitors chart for " + days + " days"); |
27 | days = max(1, days); |
28 | exceptionToUser { |
29 | L<S> l = toLinesFullTrim(unSlackSnippet(askSelf("visitors last " + (days+1) + " days"))); |
30 | |
31 | new L<Integer> data; |
32 | for (S line : l) { |
33 | O o = safeUnstructure(line); |
34 | int n = toInt(get(o, "cookies")); |
35 | data.add(n); |
36 | } |
37 | |
38 | removeLast(data); // drop today's data - it looks bad |
39 | |
40 | ret chartBase("Visitors last " + days + " days (= cookies)", 0, data); |
41 | // base value = 0 |
42 | } |
43 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002619 |
Snippet name: | Visitors Chart (LIVE) |
Eternal ID of this version: | #1002619/5 |
Text MD5: | 98f3fe87aaf3a497921104488d42de86 |
Transpilation MD5: | 29e634e65d4adbabac994ba2cea25eae |
Author: | stefan |
Category: | javax / eleu |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-18 13:09:41 |
Source code size: | 1009 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 728 / 4862 |
Version history: | 4 change(s) |
Referenced in: | [show references] |