Skip to content

Commit

Permalink
Merge pull request #34 from Anant/fix/collections
Browse files Browse the repository at this point in the history
fix collections
  • Loading branch information
anomnaco authored Sep 12, 2024
2 parents 6aa5417 + bfeab74 commit c8de6f0
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions src/main/java/com/datastax/oss/cass_stac/service/ItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ public Map<String, String> parseDatetime(String datetime) {
result.put("maxDate", datetime);
result.put("maxOffsetDate", datetime);
}
//logger.info(result.get("minDate").toString());
//logger.info(result.get("minOffsetDate").toString());
//logger.info(result.get("maxDate").toString());
//logger.info(result.get("maxOffsetDate").toString());
return result;
}

Expand Down Expand Up @@ -315,8 +311,6 @@ else if (ids != null) {
return null;
}).filter(Objects::nonNull).toList());
}
//logger.info(partitions.toString());
//logger.info(String.valueOf(partitions.size()));
return partitions.stream().distinct().toList();
}

Expand All @@ -328,22 +322,17 @@ private List<Item> fetchItemsForPartition(String partitionId,
Integer pageSize) {
List<Item> itemPage;

Query dbQuery = Query.query(Criteria.where("partition_id").is(partitionId))
;
if (collectionsArray != null) {
dbQuery = dbQuery.and(Criteria.where("collection").in(collectionsArray));
Query dbQuery = Query.query(Criteria.where("partition_id").is(partitionId));

if (collectionsArray != null && !collectionsArray.isEmpty()) {
dbQuery = dbQuery.and(Criteria.where("collection").in(collectionsArray)).withAllowFiltering();
}

dbQuery = dbQuery.and(Criteria.where("datetime").lte(maxDate))
.and(Criteria.where("datetime").gte(minDate));

//logger.info("dbQuery.toString()");
//logger.info(dbQuery.toString());
itemPage = cassandraTemplate.select(dbQuery, Item.class);

//logger.info("itemPage.toString()");
//logger.info(itemPage.toString());


return itemPage;
}
Expand All @@ -357,23 +346,17 @@ private CompletableFuture<List<Item>> fetchItemsForPartitionAsync(String partiti
Integer pageSize) {
List<Item> itemPage;

Query dbQuery = Query.query(Criteria.where("partition_id").is(partitionId))
;
if (collectionsArray != null) {
dbQuery = dbQuery.and(Criteria.where("collection").in(collectionsArray));
Query dbQuery = Query.query(Criteria.where("partition_id").is(partitionId));

if (collectionsArray != null && !collectionsArray.isEmpty()) {
dbQuery = dbQuery.and(Criteria.where("collection").in(collectionsArray)).withAllowFiltering();
}

dbQuery = dbQuery.and(Criteria.where("datetime").lte(maxDate))
.and(Criteria.where("datetime").gte(minDate));

//logger.info("dbQuery.toString()");
//logger.info(dbQuery.toString());
itemPage = cassandraTemplate.select(dbQuery, Item.class);

//logger.info("itemPage.toString()");
//logger.info(itemPage.toString());


return CompletableFuture.completedFuture(itemPage);
}

Expand Down

0 comments on commit c8de6f0

Please sign in to comment.