Skip to content
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

Merged
merged 36 commits into from
Jul 27, 2022

Conversation

rushtong
Copy link
Contributor

@rushtong rushtong commented Jul 12, 2022

Addresses

https://broadworkbench.atlassian.net/browse/DUOS-1764
https://broadworkbench.atlassian.net/browse/DUOS-1765

Changes

  • Update to the DAR submission process so we only create a single DAR instead of N DARs per dataset requested.
  • Updates to resource class and tests to cover this change.

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.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@rushtong rushtong changed the base branch from develop to DUOS-1763-v3 July 12, 2022 12:25
@rushtong rushtong changed the title [DUOS-1764][risk=no] Create a single DAR for N Datasets on submission [DUOS-1764, DUOS-1765][risk=no] Create a single DAR for N Datasets on submission Jul 14, 2022
Base automatically changed from DUOS-1763-v3 to develop July 15, 2022 13:37
rushtong added 4 commits July 15, 2022 11:18
# 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
Comment on lines -321 to -335
/**
* 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);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused

@rushtong rushtong marked this pull request as ready for review July 21, 2022 20:03
@rushtong rushtong requested a review from a team as a code owner July 21, 2022 20:03
@rushtong rushtong requested review from JVThomas and shaemarks July 26, 2022 13:01
@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 " +
Copy link
Contributor

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)?

Copy link
Contributor Author

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.

Copy link
Contributor

@shaemarks shaemarks left a 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.

processDataUseBuckets

@rushtong
Copy link
Contributor Author

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());
Copy link
Contributor

@JVThomas JVThomas Jul 26, 2022

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?

Copy link
Contributor

@JVThomas JVThomas left a 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.

@rushtong rushtong merged commit 492354e into develop Jul 27, 2022
@rushtong rushtong deleted the DUOS-1764 branch July 27, 2022 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants