Commit pr pr_p1 reports
This commit is contained in:
parent
7b69eb9c2a
commit
7b2786354c
|
@ -59,9 +59,10 @@ class SushiLiteController {
|
||||||
@RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
|
@RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
|
||||||
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
|
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
|
||||||
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
|
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
|
||||||
|
@RequestParam(value = "MetricType", defaultValue = "") String metricType,
|
||||||
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
|
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
|
||||||
log.info("COUNTER PR Report request for repository " + repositoryIdentifier);
|
log.info("COUNTER PR Report request for repository " + repositoryIdentifier);
|
||||||
return sushiLiteService.displayReportPR(repositoryIdentifier, beginDate, endDate, granularity);
|
return sushiLiteService.displayReportPR(repositoryIdentifier, beginDate, endDate, metricType, granularity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/sushilite/r5/reports/pr_p1", method = RequestMethod.GET)
|
@RequestMapping(value = "/sushilite/r5/reports/pr_p1", method = RequestMethod.GET)
|
||||||
|
|
|
@ -1503,7 +1503,7 @@ public class UsageStatsRepository {
|
||||||
|
|
||||||
public void executeBatchItemsPR(List<ReportItem> reportItems,
|
public void executeBatchItemsPR(List<ReportItem> reportItems,
|
||||||
String repositoryIdentifier, Date beginDate,
|
String repositoryIdentifier, Date beginDate,
|
||||||
Date endDate, String granularity) {
|
Date endDate, String metricType, String granularity) {
|
||||||
SimpleDateFormat report_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat report_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
SimpleDateFormat postgresFormat = new SimpleDateFormat("yyyy/MM");
|
SimpleDateFormat postgresFormat = new SimpleDateFormat("yyyy/MM");
|
||||||
String beginDateStr = postgresFormat.format(beginDate);
|
String beginDateStr = postgresFormat.format(beginDate);
|
||||||
|
@ -1515,7 +1515,6 @@ public class UsageStatsRepository {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
connection = usageStatsDB.getConnection();
|
connection = usageStatsDB.getConnection();
|
||||||
|
|
||||||
if (granularity.equalsIgnoreCase("totals")) {
|
if (granularity.equalsIgnoreCase("totals")) {
|
||||||
st = connection.prepareStatement("SELECT rc.type, sum(us.downloads) as downloads, sum(us.views) as views FROM " + usagestatsImpalaDB + ".usage_stats us, "
|
st = connection.prepareStatement("SELECT rc.type, sum(us.downloads) as downloads, sum(us.views) as views FROM " + usagestatsImpalaDB + ".usage_stats us, "
|
||||||
+ statsDB + ".result_classifications rc WHERE us.`date`>=? AND us.`date`<=? AND us.repository_id=? AND rc.id=us.result_id GROUP BY rc.type order by rc.type ASC;");
|
+ statsDB + ".result_classifications rc WHERE us.`date`>=? AND us.`date`<=? AND us.repository_id=? AND rc.id=us.result_id GROUP BY rc.type order by rc.type ASC;");
|
||||||
|
@ -1527,11 +1526,30 @@ public class UsageStatsRepository {
|
||||||
rs = st.executeQuery();
|
rs = st.executeQuery();
|
||||||
ReportItem reportItem = null;
|
ReportItem reportItem = null;
|
||||||
|
|
||||||
|
switch (metricType) {
|
||||||
|
case (""):
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
reportItem = new ReportItem("", "OpenAIRE", rs.getString(1), "Regular", "");
|
reportItem = new ReportItem("", "OpenAIRE", rs.getString(1), "Regular", "");
|
||||||
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), rs.getString(2), rs.getString(3)));
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), rs.getString(2), rs.getString(3)));
|
||||||
reportItems.add(reportItem);
|
reportItems.add(reportItem);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case ("Total_Items_Investigations"):
|
||||||
|
while (rs.next()) {
|
||||||
|
reportItem = new ReportItem("", "OpenAIRE", rs.getString(1), "Regular", "");
|
||||||
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), null, rs.getString(3)));
|
||||||
|
reportItems.add(reportItem);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ("Total_Items_Requests"):
|
||||||
|
while (rs.next()) {
|
||||||
|
reportItem = new ReportItem("", "OpenAIRE", rs.getString(1), "Regular", "");
|
||||||
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), rs.getString(2), null));
|
||||||
|
reportItems.add(reportItem);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (granularity.equalsIgnoreCase("monthly")) {
|
} else if (granularity.equalsIgnoreCase("monthly")) {
|
||||||
st = connection.prepareStatement("SELECT rc.type, us.`date`, sum(us.downloads) as downloads, sum(us.views) as views FROM " + usagestatsImpalaDB + ".usage_stats us, "
|
st = connection.prepareStatement("SELECT rc.type, us.`date`, sum(us.downloads) as downloads, sum(us.views) as views FROM " + usagestatsImpalaDB + ".usage_stats us, "
|
||||||
+ statsDB + ".result_classifications rc WHERE us.`date`>=? AND us.`date`<=? AND us.repository_id=? AND rc.id=us.result_id GROUP BY rc.type, us.`date` order by rc.type, us.`date` ASC;");
|
+ statsDB + ".result_classifications rc WHERE us.`date`>=? AND us.`date`<=? AND us.repository_id=? AND rc.id=us.result_id GROUP BY rc.type, us.`date` order by rc.type, us.`date` ASC;");
|
||||||
|
@ -1568,7 +1586,21 @@ public class UsageStatsRepository {
|
||||||
datatype = rs.getString(1);
|
datatype = rs.getString(1);
|
||||||
}
|
}
|
||||||
if (reportItem != null) {
|
if (reportItem != null) {
|
||||||
|
switch (metricType) {
|
||||||
|
case (""):
|
||||||
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(postgresFormat.parse(rs.getString(2))), report_dateFormat.format(endC.getTime()), rs.getString(3), rs.getString(4)));
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(postgresFormat.parse(rs.getString(2))), report_dateFormat.format(endC.getTime()), rs.getString(3), rs.getString(4)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ("Total_Items_Investigations"):
|
||||||
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(postgresFormat.parse(rs.getString(2))), report_dateFormat.format(endC.getTime()), null, rs.getString(4)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ("Total_Items_Requests"):
|
||||||
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(postgresFormat.parse(rs.getString(2))), report_dateFormat.format(endC.getTime()), rs.getString(3), null));
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
endC.setTime(postgresFormat.parse(rs.getString(2)));
|
endC.setTime(postgresFormat.parse(rs.getString(2)));
|
||||||
endC.add(Calendar.MONTH, 1);
|
endC.add(Calendar.MONTH, 1);
|
||||||
|
@ -1646,8 +1678,9 @@ public class UsageStatsRepository {
|
||||||
//if (reportItem != null) {
|
//if (reportItem != null) {
|
||||||
//fillWithZeros(postgresFormat.parse(lastDate), endDateForZeros, reportItem);
|
//fillWithZeros(postgresFormat.parse(lastDate), endDateForZeros, reportItem);
|
||||||
}
|
}
|
||||||
if(reportItem.getItemPerformances().size()>0)
|
if (reportItem.getItemPerformances().size() > 0) {
|
||||||
reportItems.add(reportItem);
|
reportItems.add(reportItem);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
jedis.put(redis_key, "persistent", "false");
|
jedis.put(redis_key, "persistent", "false");
|
||||||
|
|
|
@ -21,8 +21,8 @@ public interface SushiLiteService {
|
||||||
ArrayList buildReportSupported();
|
ArrayList buildReportSupported();
|
||||||
String displayReportsSupported();
|
String displayReportsSupported();
|
||||||
|
|
||||||
ReportPR buildReportPR(String repositoryIdentifier, String beginDate,String endDate, String granularity);
|
ReportPR buildReportPR(String repositoryIdentifier, String beginDate,String endDate, String metricType, String granularity);
|
||||||
String displayReportPR(String repositoryIdentifier, String beginDate,String endDate, String granularity);
|
String displayReportPR(String repositoryIdentifier, String beginDate,String endDate, String metricType, String granularity);
|
||||||
|
|
||||||
ReportPR buildReportPR_P1(String repositoryIdentifier, String beginDate,String endDate);
|
ReportPR buildReportPR_P1(String repositoryIdentifier, String beginDate,String endDate);
|
||||||
String displayReportPR_P1(String repositoryIdentifier, String beginDate, String endDate);
|
String displayReportPR_P1(String repositoryIdentifier, String beginDate, String endDate);
|
||||||
|
|
|
@ -300,7 +300,7 @@ public class SushiLiteServiceImpl implements SushiLiteService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReportPR buildReportPR(String repositoryIdentifier, String beginDate,
|
public ReportPR buildReportPR(String repositoryIdentifier, String beginDate,
|
||||||
String endDate, String granularity) {
|
String endDate, String metricType, String granularity) {
|
||||||
List<ReportException> reportExceptions = new ArrayList<>();
|
List<ReportException> reportExceptions = new ArrayList<>();
|
||||||
ZonedDateTime dateTime = ZonedDateTime.now(); // Gets the current date and time, with your default time-zone
|
ZonedDateTime dateTime = ZonedDateTime.now(); // Gets the current date and time, with your default time-zone
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
@ -364,7 +364,7 @@ public class SushiLiteServiceImpl implements SushiLiteService {
|
||||||
institutionIdD.add(new InstitutionID("Openaire", repositoryIdentifier));
|
institutionIdD.add(new InstitutionID("Openaire", repositoryIdentifier));
|
||||||
|
|
||||||
List<ReportItem> reportItems = new ArrayList();
|
List<ReportItem> reportItems = new ArrayList();
|
||||||
usageStatsRepository.executeBatchItemsPR(reportItems, repositoryIdentifier, beginDateParsed, endDateParsed, granularity);
|
usageStatsRepository.executeBatchItemsPR(reportItems, repositoryIdentifier, beginDateParsed, endDateParsed, metricType, granularity);
|
||||||
if (reportItems.isEmpty()) {
|
if (reportItems.isEmpty()) {
|
||||||
reportExceptions.add(new ReportException("3030", "Error", "No Usage Available for Requested Dates", "Service did not find any data"));
|
reportExceptions.add(new ReportException("3030", "Error", "No Usage Available for Requested Dates", "Service did not find any data"));
|
||||||
}
|
}
|
||||||
|
@ -458,11 +458,11 @@ public class SushiLiteServiceImpl implements SushiLiteService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String displayReportPR(String repositoryIdentifier, String beginDate,
|
public String displayReportPR(String repositoryIdentifier, String beginDate,
|
||||||
String endDate, String granularity) {
|
String endDate, String metricType, String granularity) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
log.info((beginDate + " " + endDate));
|
log.info((beginDate + " " + endDate));
|
||||||
try {
|
try {
|
||||||
return "<pre>" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(buildReportPR(repositoryIdentifier, beginDate, endDate, granularity)) + "</pre>";
|
return "<pre>" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(buildReportPR(repositoryIdentifier, beginDate, endDate, metricType, granularity)) + "</pre>";
|
||||||
} catch (JsonProcessingException ex) {
|
} catch (JsonProcessingException ex) {
|
||||||
java.util.logging.Logger.getLogger(SushiLiteServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
|
java.util.logging.Logger.getLogger(SushiLiteServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,16 @@ log4j.additivity.org.springframework = false
|
||||||
|
|
||||||
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
||||||
#log4j.appender.R.File=/var/log/dnet/usageStatsAPI/usageStatsAPI.log
|
#log4j.appender.R.File=/var/log/dnet/usageStatsAPI/usageStatsAPI.log
|
||||||
log4j.appender.R.File=/Users/dpie/Desktop/usageStatsAPI.log
|
#log4j.appender.R.File=/Users/dpie/Desktop/usageStatsAPI.log
|
||||||
#log4j.appender.R.File=/Volumes/Zeus/dpie/Desktop/usageStatsAPI.log
|
log4j.appender.R.File=/Volumes/Zeus/dpie/Desktop/usageStatsAPI.log
|
||||||
loglog4j.appender.R.MaxFileSize=10MB
|
loglog4j.appender.R.MaxFileSize=10MB
|
||||||
log4j.appender.R.MaxBackupIndex=10
|
log4j.appender.R.MaxBackupIndex=10
|
||||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
|
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
|
||||||
log4j.appender.S=org.apache.log4j.RollingFileAppender
|
log4j.appender.S=org.apache.log4j.RollingFileAppender
|
||||||
#log4j.appender.S.File=/var/log/dnet/usageStatsAPI/usageStatsAPI-spring.log
|
#log4j.appender.S.File=/var/log/dnet/usageStatsAPI/usageStatsAPI-spring.log
|
||||||
log4j.appender.S.File=/Users/dpie/Desktop/usageStatsAPI-spring.log
|
#log4j.appender.S.File=/Users/dpie/Desktop/usageStatsAPI-spring.log
|
||||||
#log4j.appender.S.File=/Volumes/Zeus/dpie/Desktop/usageStatsAPI-spring.log
|
log4j.appender.S.File=/Volumes/Zeus/dpie/Desktop/usageStatsAPI-spring.log
|
||||||
log4j.appender.S.MaxFileSize=10MB
|
log4j.appender.S.MaxFileSize=10MB
|
||||||
log4j.appender.S.MaxBackupIndex=10
|
log4j.appender.S.MaxBackupIndex=10
|
||||||
log4j.appender.S.layout=org.apache.log4j.PatternLayout
|
log4j.appender.S.layout=org.apache.log4j.PatternLayout
|
||||||
|
|
Loading…
Reference in New Issue