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 = "BeginDate", defaultValue = "") String beginDate,
|
||||
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
|
||||
@RequestParam(value = "MetricType", defaultValue = "") String metricType,
|
||||
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
|
||||
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)
|
||||
|
|
|
@ -1503,7 +1503,7 @@ public class UsageStatsRepository {
|
|||
|
||||
public void executeBatchItemsPR(List<ReportItem> reportItems,
|
||||
String repositoryIdentifier, Date beginDate,
|
||||
Date endDate, String granularity) {
|
||||
Date endDate, String metricType, String granularity) {
|
||||
SimpleDateFormat report_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat postgresFormat = new SimpleDateFormat("yyyy/MM");
|
||||
String beginDateStr = postgresFormat.format(beginDate);
|
||||
|
@ -1515,7 +1515,6 @@ public class UsageStatsRepository {
|
|||
|
||||
try {
|
||||
connection = usageStatsDB.getConnection();
|
||||
|
||||
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, "
|
||||
+ 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();
|
||||
ReportItem reportItem = null;
|
||||
|
||||
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), rs.getString(3)));
|
||||
reportItems.add(reportItem);
|
||||
switch (metricType) {
|
||||
case (""):
|
||||
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), rs.getString(3)));
|
||||
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")) {
|
||||
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;");
|
||||
|
@ -1568,7 +1586,21 @@ public class UsageStatsRepository {
|
|||
datatype = rs.getString(1);
|
||||
}
|
||||
if (reportItem != null) {
|
||||
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(postgresFormat.parse(rs.getString(2))), report_dateFormat.format(endC.getTime()), rs.getString(3), rs.getString(4)));
|
||||
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)));
|
||||
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.add(Calendar.MONTH, 1);
|
||||
|
@ -1646,8 +1678,9 @@ public class UsageStatsRepository {
|
|||
//if (reportItem != null) {
|
||||
//fillWithZeros(postgresFormat.parse(lastDate), endDateForZeros, reportItem);
|
||||
}
|
||||
if(reportItem.getItemPerformances().size()>0)
|
||||
if (reportItem.getItemPerformances().size() > 0) {
|
||||
reportItems.add(reportItem);
|
||||
}
|
||||
|
||||
/*
|
||||
jedis.put(redis_key, "persistent", "false");
|
||||
|
|
|
@ -21,8 +21,8 @@ public interface SushiLiteService {
|
|||
ArrayList buildReportSupported();
|
||||
String displayReportsSupported();
|
||||
|
||||
ReportPR buildReportPR(String repositoryIdentifier, String beginDate,String endDate, String granularity);
|
||||
String displayReportPR(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 metricType, String granularity);
|
||||
|
||||
ReportPR buildReportPR_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
|
||||
public ReportPR buildReportPR(String repositoryIdentifier, String beginDate,
|
||||
String endDate, String granularity) {
|
||||
String endDate, String metricType, String granularity) {
|
||||
List<ReportException> reportExceptions = new ArrayList<>();
|
||||
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'");
|
||||
|
@ -364,7 +364,7 @@ public class SushiLiteServiceImpl implements SushiLiteService {
|
|||
institutionIdD.add(new InstitutionID("Openaire", repositoryIdentifier));
|
||||
|
||||
List<ReportItem> reportItems = new ArrayList();
|
||||
usageStatsRepository.executeBatchItemsPR(reportItems, repositoryIdentifier, beginDateParsed, endDateParsed, granularity);
|
||||
usageStatsRepository.executeBatchItemsPR(reportItems, repositoryIdentifier, beginDateParsed, endDateParsed, metricType, granularity);
|
||||
if (reportItems.isEmpty()) {
|
||||
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
|
||||
public String displayReportPR(String repositoryIdentifier, String beginDate,
|
||||
String endDate, String granularity) {
|
||||
String endDate, String metricType, String granularity) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
log.info((beginDate + " " + endDate));
|
||||
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) {
|
||||
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.File=/var/log/dnet/usageStatsAPI/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=/Users/dpie/Desktop/usageStatsAPI.log
|
||||
log4j.appender.R.File=/Volumes/Zeus/dpie/Desktop/usageStatsAPI.log
|
||||
loglog4j.appender.R.MaxFileSize=10MB
|
||||
log4j.appender.R.MaxBackupIndex=10
|
||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
|
||||
log4j.appender.S=org.apache.log4j.RollingFileAppender
|
||||
#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=/Volumes/Zeus/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.MaxFileSize=10MB
|
||||
log4j.appender.S.MaxBackupIndex=10
|
||||
log4j.appender.S.layout=org.apache.log4j.PatternLayout
|
||||
|
|
Loading…
Reference in New Issue