diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java index af05fe8..a76795d 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java @@ -208,11 +208,9 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect startKey.add(scope); ArrayNode endKey = new ObjectMapper().createArrayNode(); endKey.add(scope); - - String pluginName = pluginDeclaration.getName(); - if(pluginName!=null && pluginName.compareTo("")!=0){ - startKey.add(pluginName); - endKey.add(pluginName); + if(pluginDeclaration!=null && pluginDeclaration.getName()!=null && pluginDeclaration.getName().compareTo("")!=0){ + startKey.add(pluginDeclaration.getName()); + endKey.add(pluginDeclaration.getName()); query = query.viewName(PLUGIN_STATE_VIEW_ABANDONED); }else{ query = query.viewName(PLUGIN_STATE); @@ -224,15 +222,20 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect if(iterationNumber != LAST){ startKey.add(iterationNumber); endKey.add(iterationNumber); + + startKey.add(1); + endKey.add("{}"); + }else{ + // Adding time interval + startKey.add(1); + endKey.add("{}"); } - - // Adding time interval - startKey.add(1); - endKey.add("{}"); query.startKey(startKey); query.endKey(endKey); + query.reduce(false); + PluginState pluginState = null; ViewResult viewResult = query(query); for (ViewResult.Row row : viewResult) {