fixed bug in counting page accesses
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@169293 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
85ea36fb00
commit
6281106d7a
|
@ -52,14 +52,12 @@ import com.google.api.client.util.PemReader.Section;
|
|||
import com.google.api.client.util.SecurityUtils;
|
||||
import com.google.api.services.analyticsreporting.v4.AnalyticsReporting;
|
||||
import com.google.api.services.analyticsreporting.v4.AnalyticsReportingScopes;
|
||||
import com.google.api.services.analyticsreporting.v4.model.ColumnHeader;
|
||||
import com.google.api.services.analyticsreporting.v4.model.DateRange;
|
||||
import com.google.api.services.analyticsreporting.v4.model.DateRangeValues;
|
||||
import com.google.api.services.analyticsreporting.v4.model.Dimension;
|
||||
import com.google.api.services.analyticsreporting.v4.model.GetReportsRequest;
|
||||
import com.google.api.services.analyticsreporting.v4.model.GetReportsResponse;
|
||||
import com.google.api.services.analyticsreporting.v4.model.Metric;
|
||||
import com.google.api.services.analyticsreporting.v4.model.MetricHeaderEntry;
|
||||
import com.google.api.services.analyticsreporting.v4.model.Report;
|
||||
import com.google.api.services.analyticsreporting.v4.model.ReportRequest;
|
||||
import com.google.api.services.analyticsreporting.v4.model.ReportRow;
|
||||
|
@ -100,10 +98,10 @@ public class VREAccessesHarvester extends BasicHarvester {
|
|||
if(!pagePath.contains("_redirect=/group")) {
|
||||
if(pagePath.endsWith(lowerCasedContext)) {
|
||||
logger.trace("Matched endsWith({}) : {}", lowerCasedContext, pagePath);
|
||||
measure++;
|
||||
measure += row.getVisitNumber();
|
||||
} else if(pagePath.contains(case1) || pagePath.contains(case2)) {
|
||||
logger.trace("Matched contains({}) || contains({}) : {}", case1, case2, pagePath);
|
||||
measure++;
|
||||
measure += row.getVisitNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,48 +194,41 @@ public class VREAccessesHarvester extends BasicHarvester {
|
|||
return reports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and prints the Analytics Reporting API V4 response.
|
||||
*
|
||||
* @param response An Analytics Reporting API V4 response.
|
||||
*/
|
||||
/**
|
||||
* Parses and prints the Analytics Reporting API V4 response.
|
||||
*
|
||||
* @param response An Analytics Reporting API V4 response.
|
||||
*/
|
||||
private static List<VREAccessesReportRow> parseResponse(String viewId, GetReportsResponse response) {
|
||||
logger.trace("\n*** parsing Response for {}", viewId);
|
||||
logger.debug("parsing Response for " + viewId);
|
||||
|
||||
List<VREAccessesReportRow> toReturn = new ArrayList<>();
|
||||
|
||||
for (Report report: response.getReports()) {
|
||||
ColumnHeader header = report.getColumnHeader();
|
||||
List<String> dimensionHeaders = header.getDimensions();
|
||||
List<MetricHeaderEntry> metricHeaders = header.getMetricHeader().getMetricHeaderEntries();
|
||||
List<ReportRow> rows = report.getData().getRows();
|
||||
|
||||
if (rows == null) {
|
||||
logger.warn("No data found for " + viewId);
|
||||
} else
|
||||
}
|
||||
else {
|
||||
for (ReportRow row: rows) {
|
||||
List<String> dimensions = row.getDimensions();
|
||||
List<DateRangeValues> metrics = row.getMetrics();
|
||||
|
||||
String dimension = row.getDimensions().get(0);
|
||||
DateRangeValues metric = row.getMetrics().get(0);
|
||||
VREAccessesReportRow var = new VREAccessesReportRow();
|
||||
boolean validEntry = false;
|
||||
for(int i = 0; i < dimensionHeaders.size() && i < dimensions.size(); i++) {
|
||||
//logger.trace("{} : {}", dimensionHeaders.get(i), dimensions.get(i));
|
||||
String pagePath = dimensions.get(i);
|
||||
String pagePath = dimension;
|
||||
if (pagePath.startsWith("/group") || pagePath.startsWith("/web")) {
|
||||
var.setPagePath(dimensions.get(i));
|
||||
var.setPagePath(dimension);
|
||||
validEntry = true;
|
||||
}
|
||||
}
|
||||
if (validEntry) {
|
||||
for(int j = 0; j < metrics.size(); j++) {
|
||||
DateRangeValues values = metrics.get(j);
|
||||
for(int k = 0; k < values.getValues().size() && k < metricHeaders.size(); k++) {
|
||||
var.setVisitNumber(Integer.parseInt(values.getValues().get(k)));
|
||||
}
|
||||
}
|
||||
var.setVisitNumber(Integer.parseInt(metric.getValues().get(0)));
|
||||
toReturn.add(var);
|
||||
logger.debug(var.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue