info method
This commit is contained in:
parent
ca04c6db71
commit
8a8507e8af
|
@ -8,8 +8,6 @@ import org.springframework.cache.annotation.CacheEvict;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.app.directindex.clients.model.ProjectInfo;
|
||||
|
||||
@Component
|
||||
public class ProjectClient implements HasCache {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.app.directindex.clients.model;
|
||||
package eu.dnetlib.app.directindex.clients;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.app.directindex.controllers;
|
|||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -30,6 +31,11 @@ public class AdminController {
|
|||
@Autowired
|
||||
private List<HasCache> clients;
|
||||
|
||||
@GetMapping("/info")
|
||||
public Map<String, ?> info() {
|
||||
return service.getInfo();
|
||||
}
|
||||
|
||||
@DeleteMapping("/other-caches")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void evictCaches() {
|
||||
|
|
|
@ -18,8 +18,8 @@ import eu.dnetlib.app.directindex.clients.CommunityClient;
|
|||
import eu.dnetlib.app.directindex.clients.CommunityClient.ContextInfo;
|
||||
import eu.dnetlib.app.directindex.clients.DatasourceManagerClient;
|
||||
import eu.dnetlib.app.directindex.clients.ProjectClient;
|
||||
import eu.dnetlib.app.directindex.clients.ProjectInfo;
|
||||
import eu.dnetlib.app.directindex.clients.VocabularyClient;
|
||||
import eu.dnetlib.app.directindex.clients.model.ProjectInfo;
|
||||
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
|
||||
import eu.dnetlib.app.directindex.input.DatasourceEntry;
|
||||
import eu.dnetlib.app.directindex.input.PidEntry;
|
||||
|
|
|
@ -31,4 +31,22 @@ public interface PendingActionRepository extends JpaRepository<PendingAction, St
|
|||
@Query(value = "update pending_actions set execution_date = null where id = ?1", nativeQuery = true)
|
||||
void resetExecution(String id);
|
||||
|
||||
long countByExecutionDateIsNull();
|
||||
|
||||
long countByOperation(OperationType operation);
|
||||
|
||||
long countByOperationAndExecutionDateIsNull(OperationType operation);
|
||||
|
||||
@Query(value = "select min(creation_date) from pending_actions", nativeQuery = true)
|
||||
LocalDateTime findMinCreationDate();
|
||||
|
||||
@Query(value = "select max(creation_date) from pending_actions", nativeQuery = true)
|
||||
LocalDateTime findMaxCreationDate();
|
||||
|
||||
@Query(value = "select min(execution_date) from pending_actions", nativeQuery = true)
|
||||
LocalDateTime findMinExecutionDate();
|
||||
|
||||
@Query(value = "select max(execution_date) from pending_actions", nativeQuery = true)
|
||||
LocalDateTime findMaxExecutionDate();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.dnetlib.app.directindex.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
|
@ -112,4 +114,26 @@ public class DirectIndexService {
|
|||
public void resetExecutions(final String id) {
|
||||
pendingActionRepository.resetExecution(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Map<String, ?> getInfo() {
|
||||
final Map<String, Object> info = new LinkedHashMap<String, Object>();
|
||||
|
||||
info.put("total_actions", pendingActionRepository.count());
|
||||
info.put("total_actions_insert", pendingActionRepository.countByOperation(OperationType.INSERT));
|
||||
info.put("total_actions_update", pendingActionRepository.countByOperation(OperationType.UPDATE));
|
||||
info.put("total_actions_delete", pendingActionRepository.countByOperation(OperationType.DELETE));
|
||||
|
||||
info.put("pending_actions", pendingActionRepository.countByExecutionDateIsNull());
|
||||
info.put("pending_actions_insert", pendingActionRepository.countByOperationAndExecutionDateIsNull(OperationType.INSERT));
|
||||
info.put("pending_actions_update", pendingActionRepository.countByOperationAndExecutionDateIsNull(OperationType.UPDATE));
|
||||
info.put("pending_actions_delete", pendingActionRepository.countByOperationAndExecutionDateIsNull(OperationType.DELETE));
|
||||
|
||||
info.put("min_registration_date", pendingActionRepository.findMinCreationDate());
|
||||
info.put("max_registration_date", pendingActionRepository.findMaxCreationDate());
|
||||
info.put("min_execution_date", pendingActionRepository.findMinExecutionDate());
|
||||
info.put("max_execution_date", pendingActionRepository.findMaxExecutionDate());
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import eu.dnetlib.app.directindex.clients.CommunityClient;
|
||||
import eu.dnetlib.app.directindex.clients.DatasourceManagerClient;
|
||||
import eu.dnetlib.app.directindex.clients.ProjectClient;
|
||||
import eu.dnetlib.app.directindex.clients.ProjectInfo;
|
||||
import eu.dnetlib.app.directindex.clients.VocabularyClient;
|
||||
import eu.dnetlib.app.directindex.clients.model.ProjectInfo;
|
||||
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
|
||||
import eu.dnetlib.app.directindex.input.DatasourceEntry;
|
||||
import eu.dnetlib.app.directindex.input.ResultEntry;
|
||||
|
|
Loading…
Reference in New Issue