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

Remove corresponding issues on branch delete #1224

Open
wants to merge 13 commits into
base: 9.x
Choose a base branch
from

Conversation

AAAlinaaa
Copy link
Contributor

No description provided.

@AAAlinaaa AAAlinaaa self-assigned this Sep 29, 2023
@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (e57082a) 47.96% compared to head (c96bc96) 48.00%.
Report is 3 commits behind head on 9.x.

Files Patch % Lines
.../snowowl/core/branch/ValidationCleanupService.java 67.56% 11 Missing and 1 partial ⚠️
...ional/snowowl/core/branch/BranchDeleteRequest.java 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                9.x    #1224      +/-   ##
============================================
+ Coverage     47.96%   48.00%   +0.04%     
- Complexity    13831    13852      +21     
============================================
  Files          1942     1943       +1     
  Lines         94946    94989      +43     
  Branches      10955    10957       +2     
============================================
+ Hits          45541    45600      +59     
+ Misses        46378    46360      -18     
- Partials       3027     3029       +2     

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

removeStaleIssues(context, List.of(resourceURI), previousAnalysisRunIds);
}

public void removeStaleIssues(ServiceProvider context, List<String> resourceURIs, List<String> previousAnalysisRunIds) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void removeStaleIssues(ServiceProvider context, List<String> resourceURIs, List<String> previousAnalysisRunIds) {
public void removeStaleIssues(ServiceProvider context, List<String> resourceURIs, List<String> resultIds) {

removeStaleIssues(context, resourceURIs, Collections.emptyList());
}

public void removeStaleIssues(ServiceProvider context, String resourceURI, List<String> previousAnalysisRunIds) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void removeStaleIssues(ServiceProvider context, String resourceURI, List<String> previousAnalysisRunIds) {
public void removeStaleIssues(ServiceProvider context, String resourceURI, List<String> resultIds) {

public void removeStaleIssues(ServiceProvider context, List<String> resourceURIs, List<String> previousAnalysisRunIds) {
AsyncRequest<Boolean> request;

if (!previousAnalysisRunIds.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!previousAnalysisRunIds.isEmpty()) {
if (!CompareUtils.isEmpty(resultIds)) {

} else {
request = ValidationRequests.issues()
.prepareDelete()
.setCodeSystemURIs(resourceURIs)
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the resourceURIs is null or empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing good, we shouldn't delete without resource uri filters.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but that's a flaw in the API. If the caller should only use one input parameter, then we should split this method into two separate implementations instead of merging them into one with if else blocks.

.buildAsync();
}

final String description = String.format("Remove validation issues on stale/removed branch(es) %s", Joiner.on(", ").join(resourceURIs));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
final String description = String.format("Remove validation issues on stale/removed branch(es) %s", Joiner.on(", ").join(resourceURIs));
final String description = String.format("Remove validation issues on stale/removed branch(es) of '%s'", Joiner.on(", ").join(resourceURIs));

public ValidationCleanupService() {
}

public void removeStaleIssues(ServiceProvider context, String resourceURI) {
Copy link
Member

Choose a reason for hiding this comment

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

Rename all these methods to scheduleStaleIssueRemoval since it is not actually removing anything from the index but schedules a job that removes it.

@cmark cmark requested a review from apeteri November 22, 2023 10:03
Copy link
Member

@apeteri apeteri left a comment

Choose a reason for hiding this comment

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

👍 with a suggestion below.

JobRequests.prepareSchedule()
.setRequest(request)
.setDescription(description)
.setUser(context.service(User.class).getUserId())
Copy link
Member

Choose a reason for hiding this comment

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

This is the default behavior in ScheduleJobRequest, you can leave this property unset if you don't want to override the requester:

final String userId = !Strings.isNullOrEmpty(user) ? user : context.service(User.class).getUserId();

@AAAlinaaa AAAlinaaa force-pushed the issue/SO-5533-clear-stale-validation-issues branch from dc8f309 to 8500f18 Compare December 6, 2023 17:07
try {
//Schedule a job to remove issues corresponding to this branch
TerminologyResource resource = context.service(PathTerminologyResourceResolver.class).resolve(context, context.info().id(), getBranchPath());
String resourceURI = resource.getResourceURI(getBranchPath()).toString();
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we have to treat the new tilde path variants (XZX~branch) as well here. Could you please add support for that?

@@ -0,0 +1,79 @@
package com.b2international.snowowl.core.branch;
Copy link
Member

Choose a reason for hiding this comment

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

Missing license and since tag.

} else {
request = ValidationRequests.issues()
.prepareDelete()
.setCodeSystemURIs(resourceURIs)
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but that's a flaw in the API. If the caller should only use one input parameter, then we should split this method into two separate implementations instead of merging them into one with if else blocks.

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.

None yet

3 participants