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.client.util.SecurityUtils;
|
||||||
import com.google.api.services.analyticsreporting.v4.AnalyticsReporting;
|
import com.google.api.services.analyticsreporting.v4.AnalyticsReporting;
|
||||||
import com.google.api.services.analyticsreporting.v4.AnalyticsReportingScopes;
|
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.DateRange;
|
||||||
import com.google.api.services.analyticsreporting.v4.model.DateRangeValues;
|
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.Dimension;
|
||||||
import com.google.api.services.analyticsreporting.v4.model.GetReportsRequest;
|
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.GetReportsResponse;
|
||||||
import com.google.api.services.analyticsreporting.v4.model.Metric;
|
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.Report;
|
||||||
import com.google.api.services.analyticsreporting.v4.model.ReportRequest;
|
import com.google.api.services.analyticsreporting.v4.model.ReportRequest;
|
||||||
import com.google.api.services.analyticsreporting.v4.model.ReportRow;
|
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.contains("_redirect=/group")) {
|
||||||
if(pagePath.endsWith(lowerCasedContext)) {
|
if(pagePath.endsWith(lowerCasedContext)) {
|
||||||
logger.trace("Matched endsWith({}) : {}", lowerCasedContext, pagePath);
|
logger.trace("Matched endsWith({}) : {}", lowerCasedContext, pagePath);
|
||||||
measure++;
|
measure += row.getVisitNumber();
|
||||||
} else if(pagePath.contains(case1) || pagePath.contains(case2)) {
|
} else if(pagePath.contains(case1) || pagePath.contains(case2)) {
|
||||||
logger.trace("Matched contains({}) || contains({}) : {}", case1, case2, pagePath);
|
logger.trace("Matched contains({}) || contains({}) : {}", case1, case2, pagePath);
|
||||||
measure++;
|
measure += row.getVisitNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,50 +194,43 @@ public class VREAccessesHarvester extends BasicHarvester {
|
||||||
return reports;
|
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.
|
* Parses and prints the Analytics Reporting API V4 response.
|
||||||
*
|
*
|
||||||
* @param response An Analytics Reporting API V4 response.
|
* @param response An Analytics Reporting API V4 response.
|
||||||
*/
|
*/
|
||||||
private static List<VREAccessesReportRow> parseResponse(String viewId, GetReportsResponse 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<>();
|
List<VREAccessesReportRow> toReturn = new ArrayList<>();
|
||||||
|
|
||||||
for(Report report : response.getReports()) {
|
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();
|
List<ReportRow> rows = report.getData().getRows();
|
||||||
|
if (rows == null) {
|
||||||
if(rows == null) {
|
|
||||||
logger.warn("No data found for " + viewId);
|
logger.warn("No data found for " + viewId);
|
||||||
} else
|
}
|
||||||
for(ReportRow row : rows) {
|
else {
|
||||||
List<String> dimensions = row.getDimensions();
|
for (ReportRow row: rows) {
|
||||||
List<DateRangeValues> metrics = row.getMetrics();
|
String dimension = row.getDimensions().get(0);
|
||||||
|
DateRangeValues metric = row.getMetrics().get(0);
|
||||||
VREAccessesReportRow var = new VREAccessesReportRow();
|
VREAccessesReportRow var = new VREAccessesReportRow();
|
||||||
boolean validEntry = false;
|
boolean validEntry = false;
|
||||||
for(int i = 0; i < dimensionHeaders.size() && i < dimensions.size(); i++) {
|
String pagePath = dimension;
|
||||||
//logger.trace("{} : {}", dimensionHeaders.get(i), dimensions.get(i));
|
if (pagePath.startsWith("/group") || pagePath.startsWith("/web")) {
|
||||||
String pagePath = dimensions.get(i);
|
var.setPagePath(dimension);
|
||||||
if(pagePath.startsWith("/group") || pagePath.startsWith("/web")) {
|
validEntry = true;
|
||||||
var.setPagePath(dimensions.get(i));
|
|
||||||
validEntry = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(validEntry) {
|
if (validEntry) {
|
||||||
for(int j = 0; j < metrics.size(); j++) {
|
var.setVisitNumber(Integer.parseInt(metric.getValues().get(0)));
|
||||||
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)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toReturn.add(var);
|
toReturn.add(var);
|
||||||
logger.debug(var.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue