Skip to content

Commit

Permalink
Loading the pages takes too long (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
mPokornyETM authored Nov 24, 2023
1 parent d4e51cc commit 71f6e7c
Show file tree
Hide file tree
Showing 12 changed files with 506 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,22 @@ public boolean hasLabel(String labelToFind) {
}

// ----------------------------------------------------------------------------
/**
* @deprecated Use isValidLabel(String candidate)
*/
@Deprecated
@ExcludeFromJacocoGeneratedReport
public boolean isValidLabel(String candidate, Map<String, Object> params) {
return isValidLabel(candidate);
}

// ----------------------------------------------------------------------------
/** Check if the given *candidate* label is valid or not.
* candidate may be one label or Label expression (see also
* https://www.jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#node-allocate-node).
* Valid means that the resource contains the label or the Label-expression matched.
*/
public boolean isValidLabel(String candidate) {
if (candidate == null || candidate.isEmpty()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public Set<String> getAllLabels() {
return labels;
}

// ---------------------------------------------------------------------------
public int getFreeResourceAmount(String label) {
int free = 0;
for (LockableResource r : this.resources) {
Expand All @@ -195,17 +196,45 @@ public int getFreeResourceAmount(String label) {
return free;
}

// ---------------------------------------------------------------------------
/**
* @deprecated Use getResourcesWithLabel(String label)
*/
@Deprecated
@Restricted(NoExternalUse.class)
@ExcludeFromJacocoGeneratedReport
public List<LockableResource> getResourcesWithLabel(String label, Map<String, Object> params) {
return getResourcesWithLabel(label);
}

// ---------------------------------------------------------------------------
/**
* Returns resources matching by given *label*.
* Note: The param *params* is not used (has no effect)
*/
@NonNull
@Restricted(NoExternalUse.class)
public List<LockableResource> getResourcesWithLabel(final String label) {
return _getResourcesWithLabel(label, this.getResources());
}

// ---------------------------------------------------------------------------
@NonNull
private static List<LockableResource> _getResourcesWithLabel(String label, final List<LockableResource> resources) {
List<LockableResource> found = new ArrayList<>();
if (label == null || label.isEmpty()) {
label = Util.fixEmpty(label);

if (label == null) {
return found;
}
for (LockableResource r : this.resources) {
if (r.isValidLabel(label, params)) found.add(r);

for (LockableResource r : resources) {
if (r != null && r.isValidLabel(label)) found.add(r);

Check warning on line 232 in src/main/java/org/jenkins/plugins/lockableresources/LockableResourcesManager.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 232 is only partially covered, one branch is missing
}
return found;
}

// ---------------------------------------------------------------------------
/**
* Get a list of resources matching the script.
*
Expand Down
Loading

0 comments on commit 71f6e7c

Please sign in to comment.