Skip to content

Commit

Permalink
Added a sanity test that harvest ids returned are unique.
Browse files Browse the repository at this point in the history
  • Loading branch information
csrster committed Nov 15, 2017
1 parent 334efe5 commit 7175f0a
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -677,7 +677,14 @@ public Iterable<Long> getReadyHarvestDefinitions(Date now) {
+ " FROM partialharvests, harvestdefinitions"
+ " WHERE harvestdefinitions.harvest_id = partialharvests.harvest_id"
+ " AND isactive = ? AND nextdate IS NOT NULL AND nextdate < ?", true, now));
return ids;
Set<Long> distinctIds = new HashSet<>();
distinctIds.addAll(ids);
if (distinctIds.size() != ids.size()) {
log.warn("Query returned multiple identical ids {}. These have been sanitized.", ids);
return distinctIds;
} else {
return ids;
}
} finally {
HarvestDBConnection.release(connection);
}
Expand Down

1 comment on commit 7175f0a

@nclarkekb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SELECT DISTINCT would also have worked.
Although not given a log warning which is suspect may have been the ulterior motive...

Please sign in to comment.