19 package org.turro.activity;
21 import java.util.List;
23 import java.util.TreeMap;
24 import org.turro.elephant.context.IConstructor;
25 import org.turro.elephant.db.ElephantPU;
26 import org.turro.jpa.Dao;
27 import org.turro.marker.ElephantMarker;
28 import org.turro.sql.SqlClause;
29 import org.turro.util.Cached;
30 import org.turro.util.Converter;
41 marker.
process(
"summary",
"activity");
50 private Map<String, Long> getActivities() {
51 Map<String, Long>
activities =
new TreeMap<>();
52 SqlClause.select(
"x.reason, count(x)").from(
"Activity x")
53 .where().in(
"x.reason", List.of(
"REASON_SEEN",
"Related polls"))
56 .forEach(Object[].
class, sv -> {
58 translate(Converter.STANDARD.convert(sv[0], String.class)),
59 Converter.STANDARD.convert(sv[1], Long.class));
61 SqlClause.select(
"x.entityPath, count(x)").from(
"SystemLog x")
62 .where().in(
"x.entityPath", List.of(
"/log/in",
"/log/profile"))
63 .groupBy(
"x.entityPath")
65 .forEach(Object[].
class, sv -> {
67 translate(Converter.STANDARD.convert(sv[0], String.class)),
68 Converter.STANDARD.convert(sv[1], Long.class));
70 SqlClause.select(
"x.comment, count(x)").from(
"SystemLog x")
71 .where().in(
"x.comment", List.of(
"downloaded",
"uploaded"))
74 .forEach(Object[].
class, sv -> {
76 translate(Converter.STANDARD.convert(sv[0], String.class)),
77 Converter.STANDARD.convert(sv[1], Long.class));
79 SqlClause.select(
"count(distinct x.contactId), count(x)").from(
"ActivityAssistant x")
81 .forEach(Object[].
class, sv -> {
83 "Active participants",
84 Converter.STANDARD.convert(sv[0], Long.class));
86 "Total participation",
87 Converter.STANDARD.convert(sv[1], Long.class));
94 private static Map<String, String> friendly = Map.of(
95 "REASON_SEEN",
"Visualizations",
96 "Related polls",
"Polls",
98 "/log/profile",
"Profile updates",
99 "uploaded",
"Documents uploaded",
100 "downloaded",
"Documents downloaded"
103 private String translate(String label) {
104 return friendly.getOrDefault(label, label);
static Map< String, Long > activities()
static void render(IConstructor constructor)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)