-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DUOS-1764, DUOS-1765][risk=no] Create a single DAR for N Datasets on submission #1648
Conversation
# Conflicts: # src/main/java/org/broadinstitute/consent/http/service/DataAccessRequestService.java # src/main/java/org/broadinstitute/consent/http/service/ElectionService.java # src/test/java/org/broadinstitute/consent/http/db/DataAccessRequestDAOTest.java
# Conflicts: # src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java # src/main/java/org/broadinstitute/consent/http/db/mapper/DataAccessRequestReducer.java
/** | ||
* Returns all dataset_ids that match any of the referenceIds inside of the "referenceIds" list | ||
* | ||
* @param referenceIds List<String> | ||
*/ | ||
@RegisterRowMapper(DarDatasetMapper.class) | ||
@SqlQuery("SELECT distinct reference_id, dataset_id FROM dar_dataset WHERE reference_id IN (<referenceIds>)") | ||
List<DarDataset> findAllDARDatasets(@BindList("referenceIds") List<String> referenceIds); | ||
|
||
@SqlQuery( | ||
" SELECT distinct d.reference_id " | ||
+ " FROM dar_dataset d " | ||
+ " INNER JOIN data_access_request dar ON dar.reference_id = d.reference_id AND dar.collection_id = :collectionId " | ||
+ " WHERE d.dataset_id IN <datasetIds> ") | ||
List<String> findReferenceIdsForDatasetIdsWithCollectionId( | ||
@BindList("datasetIds") List<Integer> datasetIds, @Bind("collectionId") Integer collectionId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
@SqlQuery( | ||
" SELECT e.* " + | ||
" FROM election e " + | ||
" INNER JOIN (SELECT referenceid, datasetid, MAX(createdate) max_date FROM election WHERE LOWER(electiontype) = lower(:type) AND datasetid = :datasetId GROUP BY referenceid, datasetid) election_view " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use MAX(createdate) over something like MAX(electionid)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly because we use it a lot in other queries. I believe both approaches will work equally well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! When run locally with the ui, I submitted a multi-dataset dar, and the resulting collection contained the single dar with all of the datasets.
However, I think some changes will need to be made to the bucketing logic on the frontend to support this change. The collection I created contained 4 datause buckets, each containing all of the elections since they are processed by dar. The votes are then processed by elections, so voting shouldn't be accurate with these changes.
I did actually test this case, but the bucketing and votes looked correct to me when I did so. That could have been an edge case where it worked, and there are others where it doesn't ... I'll try to dig more into the front end and figure something out. |
dar.getDatasetIds().forEach(datasetId -> { | ||
// If there is an existing open election for this DAR+Dataset, we can ignore it | ||
Election lastDataAccessElection = electionDAO.findLastElectionByReferenceIdDatasetIdAndType(dar.getReferenceId(), datasetId, ElectionType.DATA_ACCESS.getValue()); | ||
boolean ignore = Objects.nonNull(lastDataAccessElection) && lastDataAccessElection.getStatus().equals(ElectionStatus.OPEN.getValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Just to be safe, can you update the old equals
usage with equalsIgnoreCase
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick, but the code looks good. That said, Shae is right about the bucketing logic on the front-end. It needs to be updated to account for the "one dar to many elections" relationship. An update there needs to happen before this PR can go to staging/production.
Addresses
https://broadworkbench.atlassian.net/browse/DUOS-1764
https://broadworkbench.atlassian.net/browse/DUOS-1765
Changes
Note that we should immediately follow up on https://broadworkbench.atlassian.net/browse/DUOS-1961 as that story is blocked by this one and we will no longer need to archive a group of DARs (DARCollection) and recreate a new draft from them.
Have you read CONTRIBUTING.md lately? If not, do that first.