PerformanceReport.java
2.36 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.analytics.testandtarget;
import com.day.cq.analytics.testandtarget.PerformanceReportItem;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PerformanceReport {
private static final Logger LOG = LoggerFactory.getLogger(PerformanceReport.class);
private List<PerformanceReportItem> items = new ArrayList<PerformanceReportItem>();
private PerformanceReportItem totals = null;
private String winningExperienceName = "";
public void addItem(PerformanceReportItem item) {
if (item == null) {
throw new IllegalArgumentException("item may not be null");
}
if ("Activity Totals".equalsIgnoreCase(item.getExperienceName())) {
this.totals = item;
} else {
this.items.add(item);
}
}
public List<PerformanceReportItem> getItems() {
return Collections.unmodifiableList(this.items);
}
public void setWinningExperienceName(String experienceName) {
this.winningExperienceName = experienceName;
}
public String getWinningExperienceName() {
return this.winningExperienceName;
}
public PerformanceReportItem getTotalPerformance() {
int conversionCount = 0;
double engagement = 0.0;
int engagementCount = 0;
double engagementTotal = 0.0;
int entryCount = 0;
for (PerformanceReportItem item : this.items) {
conversionCount += item.getConversionCount();
engagementCount += item.getEngagementCount();
engagementTotal += item.getEngagementTotal();
entryCount += item.getEntryCount();
}
double d = engagement = engagementCount != 0 ? engagementTotal / (double)engagementCount : 0.0;
if (this.totals == null) {
this.totals = new PerformanceReportItem();
this.totals.setEntryCount(entryCount);
this.totals.setConversionRate((double)conversionCount / (double)entryCount);
}
this.totals.setConversionCount(conversionCount);
this.totals.setEngagement(engagement);
this.totals.setEngagementTotal(engagementTotal);
return this.totals;
}
}