Skip to content

Commit

Permalink
Merged in DSC-1166 (pull request DSpace#935)
Browse files Browse the repository at this point in the history
[DSC-1166] - Configured Download statistics

Approved-by: Stefano Maffei
  • Loading branch information
eskander17 authored and steph-ieffam committed Jul 28, 2023
2 parents 1faf4ec + efc5bcd commit dba7764
Show file tree
Hide file tree
Showing 11 changed files with 807 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,14 @@ public String composeFilterQuery(String startDate, String endDate, boolean relat
}

//Creates query for usage raport generator
public String composeQueryWithInverseRelation(DSpaceObject dSpaceObject, List<String> default_queries ) {
public String composeQueryWithInverseRelation(DSpaceObject dSpaceObject, List<String> default_queries, int type) {
StringBuilder query = new StringBuilder();
query.append("{!join from=search.resourceid to=id fromIndex=");
if (type == Constants.BITSTREAM) {
query.append("{!join from=search.resourceid to=owningItem fromIndex=");
} else {
query.append("{!join from=search.resourceid to=id fromIndex=");
}

query.append(configurationService.getProperty("solr.multicorePrefix"));
query.append("search} ");
boolean isFirstDefaultQuery = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Dataset getTypeStatsDataset(Context context, DSpaceObject dso, String typeAxisSt

} else {
hasValidRelation = true;
query = statisticsDatasetDisplay
.composeQueryWithInverseRelation(dso, discoveryConfiguration.getDefaultFilterQueries());
query = statisticsDatasetDisplay.composeQueryWithInverseRelation(
dso, discoveryConfiguration.getDefaultFilterQueries(), getDsoType(dso));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ private int getCategoryCount(DSpaceObject dso, DiscoveryConfiguration discoveryC
private String composeCategoryQuery(DSpaceObject dso, DiscoveryConfiguration configuration, String categoryQuery) {

List<String> defaultFilterQueries = configuration.getDefaultFilterQueries();
String query = new StatisticsDatasetDisplay().composeQueryWithInverseRelation(dso, defaultFilterQueries);
String query = new StatisticsDatasetDisplay().composeQueryWithInverseRelation(dso,
defaultFilterQueries, dso.getType());

if (categoryQuery.equals(OTHER_CATEGORY)) {
return query + " AND " + getAllCategoryQueriesReverted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ public UsageReportRest createUsageReport(Context context, DSpaceObject root, Str

} else {
hasValidRelation = true;
query = statisticsDatasetDisplay
.composeQueryWithInverseRelation(root,
discoveryConfiguration.getDefaultFilterQueries());
query = statisticsDatasetDisplay.composeQueryWithInverseRelation(root,
discoveryConfiguration.getDefaultFilterQueries(), getDsoType());
}
}
if (!hasValidRelation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public UsageReportRest createUsageReport(Context context, DSpaceObject dso, Stri

} else {
hasValidRelation = true;
query = statisticsDatasetDisplay.
composeQueryWithInverseRelation(
dso, discoveryConfiguration.getDefaultFilterQueries());
query = statisticsDatasetDisplay.composeQueryWithInverseRelation(dso,
discoveryConfiguration.getDefaultFilterQueries(), dso.getType());
}
}
if (!hasValidRelation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Dataset getDSOStatsDataset(Context context, DSpaceObject dso, int dsoType, Strin
} else {
hasValidRelation = true;
query = statisticsDatasetDisplay.composeQueryWithInverseRelation(
dso, discoveryConfiguration.getDefaultFilterQueries());
dso, discoveryConfiguration.getDefaultFilterQueries(), dso.getType());
type_of_dso = dso.getType();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public UsageReportRest createUsageReport(Context context, DSpaceObject dso, Stri
statisticsDatasetDisplay
.composeQueryWithInverseRelation(
dso,
discoveryConfiguration.getDefaultFilterQueries()
discoveryConfiguration.getDefaultFilterQueries(),
getDsoType(dso)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public class UsageReportUtils {
public static final String TOP_DOWNLOAD_COUNTRIES_REPORT_ID = "TopDownloadsCountries";
public static final String TOP_DOWNLOAD_CITIES_REPORT_ID = "TopDownloadsCities";
public static final String TOTAL_DOWNLOAD_PER_MONTH_REPORT_ID = "TotalDownloadsPerMonth";
public static final String TOP_ITEMS_CITIES_REPORT_ID = "TopItemsCities";
public static final String TOP_ITEMS_CONTINENTS_REPORT_ID = "TopItemsContinents";
public static final String TOP_ITEMS_COUNTRIES_REPORT_ID = "TopItemsCountries";
public static final String TOP_ITEMS_CATEGORIES_REPORT_ID = "TopItemsCategories";
public static final String TOTAL_ITEMS_VISITS_REPORT_ID = "TotalItemsVisits";
public static final String TOTAL_ITEMS_VISITS_PER_MONTH_REPORT_ID = "TotalItemsVisitsPerMonth";

/**
* Get list of usage reports that are applicable to the DSO (of given UUID)
Expand Down
Loading

0 comments on commit dba7764

Please sign in to comment.