Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@svonworl
Copy link
Contributor

@svonworl svonworl commented Sep 4, 2025

Description
This PR adds an endpoint that calculates the maximum weekly execution count for all versions of a workflow, for all weeks on/after a specified date.

The UI will use this endpoint to calculate the maximum Y axis value for the "small multiples" weekly execution count graphs that are being added to the versions table.

Alternatively, we could calculate the maximum client-side, by simply downloading all the versions with their metrics. However, that would be a potentially huge amount of information (some of the broad repos have more than 1000 versions) and could take seconds.

This endpoint may be ephemeral, it might be supplanted when we implement workflow-level metrics support.

The code that calculates the maximum is written with robustness in mind. It could be more efficient, but in this case, it's ok if we burn a few extra cycles.

Review Instructions
Try a few queries (like the following) and confirm that the response is rational:

curl -X POST "http://localhost:4200/api/workflows/15648/maxWeeklyExecutionCountForAnyVersion" -d '1753000000' -H 'Content-type: application/json'

Issue
https://ucsc-cgl.atlassian.net/browse/SEAB-7194

Security and Privacy

If there are any concerns that require extra attention from the security team, highlight them here and check the box when complete.

  • Security and Privacy assessed

e.g. Does this change...

  • Any user data we collect, or data location?
  • Access control, authentication or authorization?
  • Encryption features?

Please make sure that you've checked the following before submitting your pull request. Thanks!

  • Check that you pass the basic style checks and unit tests by running mvn clean install
  • Ensure that the PR targets the correct branch. Check the milestone or fix version of the ticket.
  • Follow the existing JPA patterns for queries, using named parameters, to avoid SQL injection
  • If you are changing dependencies, check the Snyk status check or the dashboard to ensure you are not introducing new high/critical vulnerabilities
  • Assume that inputs to the API can be malicious, and sanitize and/or check for Denial of Service type values, e.g., massive sizes
  • Do not serve user-uploaded binary images through the Dockstore API
  • Ensure that endpoints that only allow privileged access enforce that with the @RolesAllowed annotation
  • Do not create cookies, although this may change in the future
  • If this PR is for a user-facing feature, create and link a documentation ticket for this feature (usually in the same milestone as the linked issue). Style points if you create a documentation PR directly and link that instead.

for (int i = 0, n = values.size(); i < n; i++) {
Instant binStart = oldestBinStart.plusSeconds(i * secondsPerWeek);
Instant binEnd = binStart.plusSeconds(secondsPerWeek);
if (binEnd.compareTo(onOrAfter) >= 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this could be calculated in the JPA with a "max", but this is maybe known given

This endpoint may be ephemeral, it might be supplanted when we implement workflow-level metrics support.

@NamedQuery(name = "io.dockstore.webservice.core.Workflow.getWorkflowIdsEligibleForRetroactiveDoi", query = "SELECT DISTINCT w.id FROM Workflow w JOIN w.workflowVersions v LEFT JOIN v.versionMetadata vm LEFT JOIN vm.dois d WHERE w.isPublished AND w.autoGenerateDois AND NOT w.archived AND v.referenceType = 'TAG' AND v.valid AND NOT vm.hidden AND d IS NULL"),
@NamedQuery(name = "io.dockstore.webservice.core.Workflow.getWorkflowIdsWithGitHubOrManualDoi", query = "SELECT DISTINCT w.id FROM Workflow w JOIN w.workflowVersions v JOIN v.versionMetadata vm JOIN vm.dois d WHERE d.initiator IN ('GITHUB', 'USER')")
@NamedQuery(name = "io.dockstore.webservice.core.Workflow.getWorkflowIdsWithGitHubOrManualDoi", query = "SELECT DISTINCT w.id FROM Workflow w JOIN w.workflowVersions v JOIN v.versionMetadata vm JOIN vm.dois d WHERE d.initiator IN ('GITHUB', 'USER')"),
@NamedQuery(name = "io.dockstore.webservice.core.Workflow.getWeeklyExecutionCountsForAllVersions", query = "SELECT VALUE(c).weeklyExecutionCounts FROM Workflow w JOIN w.workflowVersions v JOIN v.metricsByPlatform mbp ON KEY(mbp) = 'ALL' JOIN VALUE(mbp).executionStatusCount esc JOIN esc.count c ON KEY(c) = 'ALL' WHERE w.id = :id AND VALUE(c).weeklyExecutionCounts IS NOT NULL"),
Copy link
Member

Choose a reason for hiding this comment

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

Could narrow things down by feeding the time into the query and not returning counts for versions that were not updated anywhere near onOrAfterEpochSecond

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.03%. Comparing base (c31093f) to head (46725aa).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ckstore/webservice/resources/WorkflowResource.java 0.00% 17 Missing ⚠️
...java/io/dockstore/webservice/jdbi/WorkflowDAO.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #6156      +/-   ##
=============================================
+ Coverage      72.32%   74.03%   +1.70%     
- Complexity      5537     5712     +175     
=============================================
  Files            397      397              
  Lines          20522    20540      +18     
  Branches        2108     2111       +3     
=============================================
+ Hits           14842    15206     +364     
+ Misses          4683     4331     -352     
- Partials         997     1003       +6     
Flag Coverage Δ
bitbuckettests 25.86% <0.00%> (-0.03%) ⬇️
hoverflytests 27.43% <0.00%> (-0.03%) ⬇️
integrationtests 56.11% <0.00%> (-0.05%) ⬇️
languageparsingtests 10.80% <0.00%> (-0.01%) ⬇️
localstacktests 21.21% <0.00%> (?)
toolintegrationtests 29.80% <0.00%> (-0.03%) ⬇️
unit-tests_and_non-confidential-tests 26.13% <0.00%> (-0.03%) ⬇️
workflowintegrationtests 38.86% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 4, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@svonworl svonworl merged commit 3adcb76 into develop Sep 4, 2025
20 of 24 checks passed
@svonworl svonworl deleted the feature/seab-7194/max-execution-count-endpoint branch September 4, 2025 22:18
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