DT-2957: Update the API call for getting DAR details for a dataset ID#2822
DT-2957: Update the API call for getting DAR details for a dataset ID#2822
Conversation
| this.electionDAO = electionDAO; | ||
| } | ||
|
|
||
| public static class DarMetricsSummary { |
There was a problem hiding this comment.
Extracted to the models package.
| * @param datasetId the id of the dataset for which to generate metrics | ||
| * @return Response containing DatasetMetrics for the given datasetId | ||
| */ | ||
| @Deprecated(forRemoval = true, since = "2026-02-23") |
There was a problem hiding this comment.
This will be removed when the front end is updated to use the GET /api/metrics/dar-summaries/{datasetId} API
There was a problem hiding this comment.
The UI only uses the dars property of this object so we're removing the dataset and elections for now. When the front end updates to the new API, this will be removed.
| void deleteByReferenceId(@Bind("referenceId") String referenceId); | ||
|
|
||
| @SqlUpdate("DELETE FROM data_access_request WHERE reference_id IN (<referenceIds>)") | ||
| void deleteByReferenceIds( |
There was a problem hiding this comment.
Drive-by fix: unused
| * @param referenceIds List<String> | ||
| */ | ||
| @SqlUpdate("DELETE FROM dar_dataset WHERE reference_id in (<referenceIds>)") | ||
| void deleteDARDatasetRelationByReferenceIds( |
There was a problem hiding this comment.
Drive-by fix: unused
src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java
Outdated
Show resolved
Hide resolved
| AND final_access_vote.last_vote = TRUE | ||
| AND (LOWER(dar.data->>'status') != 'archived' OR dar.data->>'status' IS NULL) | ||
| -- Exclude DARs that have a closeoutSupplement | ||
| AND data ->> 'closeoutSupplement' IS NULL |
There was a problem hiding this comment.
Do we really want to exclude DARs that may have been closed out? I thought this was supposed to be used to show me everything that was ever approved for a dataset, no?
There was a problem hiding this comment.
Good question. I added a parking lot item so we can discuss since I have a bigger question about what we are ultimately showing in the UI.
There was a problem hiding this comment.
I'm going to include them for now and we can revisit what the actual result looks like in a new ticket.
There was a problem hiding this comment.
Actually, this is a tougher query. Closeouts don't have elections or final votes. Will noodle on this but I'm leaning towards not including them at the moment.
src/main/java/org/broadinstitute/consent/http/models/DarMetricsSummary.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR updates the dataset metrics backend to support a new authenticated endpoint for DAR summary metrics (including an “expired” flag), while deprecating the prior unauthenticated dataset metrics route.
Changes:
- Refactors
MetricsServiceto return DAR summaries via a new DAO query that includes expired DARs. - Adds
GET /api/metrics/dar-summaries/{datasetId}and deprecatesGET /metrics/dataset/{datasetId}. - Introduces a
DarMetricsSummarymodel + tests, and updates OpenAPI docs/schemas accordingly.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/broadinstitute/consent/http/service/MetricsService.java | Reworks metrics generation to return DAR summaries (includes expired) |
| src/main/java/org/broadinstitute/consent/http/resources/MetricsResource.java | Adds new /api/metrics/dar-summaries/{datasetId} endpoint; deprecates old one |
| src/main/java/org/broadinstitute/consent/http/db/DataAccessRequestDAO.java | Adds summary-metrics query that includes expired DARs and returns dar_code |
| src/main/java/org/broadinstitute/consent/http/models/DarMetricsSummary.java | New API model for DAR summary including expired |
| src/main/java/org/broadinstitute/consent/http/models/DatasetMetrics.java | Simplifies metrics payload to only include DAR summaries |
| src/main/resources/assets/api-docs.yaml | Registers new metrics path and factors deprecated path into a separate file |
| src/main/resources/assets/paths/darSummariesByDatasetId.yaml | New OpenAPI path for DAR summaries |
| src/main/resources/assets/paths/metricsDatasetById.yaml | New OpenAPI path for deprecated dataset metrics route |
| src/main/resources/assets/schemas/DarMetric.yaml | Adds expired to DAR metric schema |
| src/main/resources/assets/schemas/DatasetMetrics.yaml | Removes dataset and elections from the schema |
| src/main/java/org/broadinstitute/consent/http/db/ElectionDAO.java | Removes unused findLastElectionsByReferenceIdsAndType |
| src/main/java/org/broadinstitute/consent/http/ConsentModule.java | Updates DI wiring for simplified MetricsService constructor |
| src/test/java/org/broadinstitute/consent/http/service/MetricsServiceTest.java | Updates tests for refactored service / new DAO method |
| src/test/java/org/broadinstitute/consent/http/resources/MetricsResourceTest.java | Adds coverage for new DAR summaries resource method |
| src/test/java/org/broadinstitute/consent/http/models/DarMetricsSummaryTest.java | New unit tests for DarMetricsSummary behavior |
| src/test/java/org/broadinstitute/consent/http/db/DataAccessRequestDAOTest.java | Adds test coverage for new “includes expired” DAO query |
| src/test/java/org/broadinstitute/consent/http/db/ElectionDAOTest.java | Minor modernizations (getFirst) and removes obsolete test |
Comments suppressed due to low confidence (2)
src/main/resources/assets/paths/darSummariesByDatasetId.yaml:16
- Response
200description says "Dataset Metrics" but this endpoint returns a list of DAR summaries, not dataset metrics. Update the response description to something like "DAR Summary Metrics" / "DAR summaries" to match the endpoint semantics.
200:
description: Dataset Metrics
content:
src/test/java/org/broadinstitute/consent/http/db/DataAccessRequestDAOTest.java:887
- This call creates an extra OPEN DataAccess election for
expiredReferenceIdbut never uses its ID and it has no votes associated, so it doesn't affect the query and is confusing in the test setup. Consider removing it (or add a comment explaining why a second election is needed).
createDataAccessElection(expiredReferenceId, dataset.getDatasetId());
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/org/broadinstitute/consent/http/models/DarMetricsSummary.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|



Addresses
https://broadworkbench.atlassian.net/browse/DT-2957
Summary
Significant refactor of the current
GET /metrics/dataset/{datasetId}API. We're deprecating that unauthenticated API in favor of an authenticated one (GET /api/metrics/dar-summaries/{datasetId}) that will return the same essential data in addition to an expired state so the UI can distinguish them in the Dataset Statistics page.This PR is required for the front end changes here: DataBiosphere/duos-ui#3343
There will be a follow-on PR that removes deprecated code right after these are merged.
Have you read CONTRIBUTING.md lately? If not, do that first.