Onto-Med / top-backend

Spring Boot based backend of the TOP Framework
MIT License
0 stars 1 forks source link

Document Count #204

Closed fmatthies closed 6 months ago

fmatthies commented 6 months ago

Right now, the document count is generated over all documents that are found in all (ES) databases that are specified by an adapter:

return getDocumentQueryService().getTextAdapterConfigs().stream()
        .map(
            c -> {
              try {
                TextAdapter adapter = TextAdapter.getInstance(c);
                return adapter.count();
              } catch (Exception e) {
                return 0L;
              }
            })
        .reduce(Long::sum)
        .orElse(0L);

Maybe it would be feasible to have a second counter, that goes over all DocumentNodes in the Neo4j Database; we could display it beside it or somewhere else and one could get an overview that not for all Documents a graph representation was created.

ChristophB commented 6 months ago

Do we need both counts? Maybe it is sufficient to just give the number of clustered documents that are stored in Neo4J.

fmatthies commented 6 months ago

Would be fine by me. I'll change it in the branch I'm working on (#197) accordingly.

fmatthies commented 6 months ago

There are now two methods, but only the first will be used to display document count on the main page.

@Cacheable("documentCount")
public long count() {
  return documentNodeRepository.count();
}
public long textAdaptersDocumentCount() {
  return getDocumentQueryService().getTextAdapterConfigs().stream()
      .map(
          c -> {
            try {
              TextAdapter adapter = TextAdapter.getInstance(c);
              return adapter.count();
            } catch (Exception e) {
              return 0L;
            }
          })
      .reduce(Long::sum)
      .orElse(0L);
}