Skip to content

fixes for get api including MDC metrics - #12741

Open
stevenwinship wants to merge 4 commits into
developfrom
491-fix-mdc-api-for-modern-ui
Open

stevenwinship wants to merge 4 commits into
developfrom
491-fix-mdc-api-for-modern-ui

Conversation

@stevenwinship

@stevenwinship stevenwinship commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:Modern UI is always getting the old metrics regardless of the DisplayMDCMetrics setting. JSF UI displays based on the setting. The response to /api/datasets/{id}/download/count?includeMDC=true or false should return the requested metrics where not including the parameter 'includeMDC' should base the output on the setting.

Which issue(s) this PR closes: IQSS/dataverse.harvard.edu#491

Special notes for your reviewer:The old code was showing MDC date when includeMDC was false. The Json response still contains the 'downloadCount' so there is no break in backward compatibility.

Suggestions on how to test this: Test with multiple variations of settings and api parameter. Downloading will increment the old metrics but not MDC. MDC needs the logs to be loaded. PSQL inserts to 'datasetmetrics' for MDC.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?: included

Additional documentation:

@stevenwinship stevenwinship self-assigned this Sep 23, 2026
@stevenwinship stevenwinship moved this to In Progress 💻 in IQSS Dataverse Project Sep 23, 2026
@stevenwinship stevenwinship added FY26 Sprint 7 FY26 Sprint 7 (2025-09-24 - 2025-10-08) FY27 Sprint 7 FY27 Sprint 7 (2026-09-23 - 2026-10-07) Size: 10 A percentage of a sprint. 7 hours. and removed FY26 Sprint 7 FY26 Sprint 7 (2025-09-24 - 2025-10-08) labels Sep 23, 2026
@coveralls

coveralls commented Sep 23, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 25.408% (-0.003%) from 25.411% — 491-fix-mdc-api-for-modern-ui into develop

@stevenwinship stevenwinship added this to the 6.13 milestone Sep 23, 2026
@stevenwinship stevenwinship added the GREI 4 Analytics and Reporting label Sep 23, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Test Results

406 tests  ±0   391 ✅ ±0   34m 2s ⏱️ +2s
 55 suites ±0    15 💤 ±0 
 55 files   ±0     0 ❌ ±0 

Results for commit 76ef0a0. ± Comparison against base commit 2553300.

♻️ This comment has been updated with latest results.

@github-actions

This comment has been minimized.

3 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@stevenwinship stevenwinship removed their assignment Sep 25, 2026
@stevenwinship
stevenwinship force-pushed the 491-fix-mdc-api-for-modern-ui branch from 1b90af6 to 76ef0a0 Compare September 25, 2026 15:40
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@ChengShi-1 ChengShi-1 self-assigned this Sep 25, 2026
@github-actions

Copy link
Copy Markdown

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:491-fix-mdc-api-for-modern-ui
ghcr.io/gdcc/configbaker:491-fix-mdc-api-for-modern-ui

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

job.add("MDC", JsonPrinter.json(metrics));
}
// total download count from guestbookResponseService and datasetMetricsService(if included)
job.add("downloadCount", count + mdcCount);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a total double-counts downloads after MDC processing.

With includeMDC=true, count contains all guestbook downloads, including those after MDCStartDate. Adding mdcCount counts events present in both sources twice.

Steps to reproduce

  1. Create a new dataset with a downloadable file and zero downloads.
  2. Set :MDCStartDate to today, enable logging with :MDCLogPath, and set :DisplayMDCMetrics=true.
  3. Download the file once using a non-admin user.
  4. Query:GET /api/datasets/{id}/download/count?includeMDC=true
    The response contains: { "downloadCount": 1, "MDC": { "downloadCount": 0 } }
  5. Run Counter Processor (with simulate_date set to tomorrow) and import the report with addUsageMetricsFromSushiReport.
  6. Without downloading again, Query:GET /api/datasets/{id}/download/count?includeMDC=true { "downloadCount": 2, "MDC": { "downloadCount": 1 } } should be shown
  7. Request includeMDC=false. It returns 0 pre-MDC downloads.

Actual: One download happened, but the API reports 2 after MDC processing. The documented subtraction also gives 2 − 1 = 1, although pre-MDC downloads are 0.
Expected: 0 pre-MDC + 1 MDC = 1 total download.

Long mdcCount = 0L;
boolean includeMDCResponse = Boolean.TRUE.equals(includeMDC);
// Setting `includeMDC` to True will ignore the `:MDCStartDate` setting and return a total count
LocalDate date = includeMDCResponse ? null : getMDCStartDate();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LocalDate date = getMDCStartDate(); so the guestbook and MDC each cover a different period, with :MDCStartDate as the boundary.

LocalDate date = includeMDC == null || !includeMDC ? getMDCStartDate() : null;
Long mdcCount = 0L;
boolean includeMDCResponse = Boolean.TRUE.equals(includeMDC);
// Setting `includeMDC` to True will ignore the `:MDCStartDate` setting and return a total count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Guestbook responses are only counted before :MDCStartDate; after that date, downloads come from MDC metrics. With includeMDC the total is the pre-MDC guestbook count + the MDC count, so no download is counted twice.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY27 Sprint 7 FY27 Sprint 7 (2026-09-23 - 2026-10-07) GREI 4 Analytics and Reporting Size: 10 A percentage of a sprint. 7 hours.

Projects

Status: In Review 🔎

Development

Successfully merging this pull request may close these issues.

3 participants