Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/main/java/gov/nih/nci/bento_ri/model/PrivateESDataFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public RuntimeWiring buildRuntimeWiring() throws IOException {
.dataFetcher("numberOfPublications", env -> {
return numberOfPublications();
})
.dataFetcher("numberOfResources", env -> {
return numberOfResources();
})
Comment thread
JoonLeeNIH marked this conversation as resolved.
.dataFetcher("datasetDetails", env -> {
Map<String, Object> args = env.getArguments();
return datasetDetails(args);
Expand Down Expand Up @@ -748,6 +751,27 @@ private Integer numberOfPublications() throws Exception {
return count;
}

/**
* Queries Opensearch for the total Resources count
* @return
* @throws Exception
*/
private Integer numberOfResources() throws Exception {
Request homeStatsRequest = new Request("GET", HOME_STATS_END_POINT);
JsonObject homeStatsResult = insEsService.send(homeStatsRequest);
JsonArray hits = homeStatsResult.getAsJsonObject("hits").getAsJsonArray("hits");
Iterator<JsonElement> hitsIter = hits.iterator();

if (!hitsIter.hasNext()) {
throw new Exception("Error: no results for homepage stats!");
}

JsonObject counts = hitsIter.next().getAsJsonObject().getAsJsonObject("_source");
int count = counts.get("num_resources").getAsInt();

return count;
Comment thread
JoonLeeNIH marked this conversation as resolved.
}

/**
* Gets the details for a single Dataset record
*
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/graphql/ins-private-es.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ type QueryType {
numberOfPrograms: Int
numberOfProjects: Int
numberOfPublications: Int
numberOfResources: Int

stats (
# Facet filters
Expand Down
Loading