@@ -21,6 +21,14 @@ public class ProjectViewEntry implements IViewEntry {
21
21
22
22
private String name ;
23
23
24
+ private TreeSet <IViewEntry > failing ;
25
+
26
+ private TreeSet <IViewEntry > completelyPassing ;
27
+
28
+ private TreeSet <IViewEntry > unstable ;
29
+
30
+ private int jobsHashCode = -1 ;
31
+
24
32
public ProjectViewEntry (String name ) {
25
33
this .name = name ;
26
34
}
@@ -40,24 +48,68 @@ public TreeSet<IViewEntry> getClaimedBuilds() {
40
48
return failing ;
41
49
}
42
50
51
+ /**
52
+ * Returns passing jobs. Passing depends on the context: if there is at
53
+ * least one failing job, then passing jobs also includes unstable ones. If
54
+ * there's no failing job, then passing will only include stable jobs.
55
+ * Unstable ones will be returned through {@link #getFailingJobs()}
56
+ *
57
+ * @return passing jobs (including unstable if there are jobs in failure).
58
+ * @see #getFailingJobs()
59
+ */
43
60
public TreeSet <IViewEntry > getPassingJobs () {
44
- TreeSet <IViewEntry > passing = new TreeSet <IViewEntry >(
45
- new EntryComparator ());
46
- for (IViewEntry job : jobs ) {
47
- if (!job .getBroken () && job .getFailCount () == 0 )
48
- passing .add (job );
61
+
62
+ computePassingAndFailingJobs ();
63
+
64
+ if (failing .size () > 0 ) {
65
+ TreeSet <IViewEntry > aggregate = new TreeSet <IViewEntry >(
66
+ new EntryComparator ());
67
+ aggregate .addAll (unstable );
68
+ aggregate .addAll (completelyPassing );
69
+ return aggregate ;
49
70
}
50
- return passing ;
71
+ return completelyPassing ;
72
+ }
73
+
74
+ /**
75
+ * Returns "failing" jobs. Depending on the context: failing will be jobs in
76
+ * "real" failure (i.e. "red") if there are indeed some jobs of this sort.
77
+ * If there aren't, then failing jobs will be unstable ones.
78
+ *
79
+ * @return "failing" jobs (unstable ones if no failing job is currently
80
+ * present).
81
+ * @see #getPassingJobs()
82
+ */
83
+ public TreeSet <IViewEntry > getFailingJobs () {
84
+ computePassingAndFailingJobs ();
85
+
86
+ if (failing .size () > 0 ) {
87
+ return failing ;
88
+ }
89
+ return unstable ;
51
90
}
52
91
53
- public TreeSet <IViewEntry > getFailingJobs () {
54
- TreeSet <IViewEntry > failing = new TreeSet <IViewEntry >(
55
- new EntryComparator ());
92
+ /**
93
+ * Computes "completelyPassing" (meaning without including unstable jobs),
94
+ * unstable and failing jobs sets. If the calculation has already been made,
95
+ * this method does nothing.
96
+ */
97
+ private void computePassingAndFailingJobs () {
98
+ if (jobsHashCode == jobs .hashCode ()) {
99
+ return ;
100
+ }
101
+ completelyPassing = new TreeSet <IViewEntry >(new EntryComparator ());
102
+ failing = new TreeSet <IViewEntry >(new EntryComparator ());
103
+ unstable = new TreeSet <IViewEntry >(new EntryComparator ());
56
104
for (IViewEntry job : jobs ) {
57
- if (job .getBroken () || job .getFailCount () > 0 )
58
- failing .add (job );
105
+ if (job .getBroken () || job .getFailCount () > 0 ) {
106
+ failing .add (job );
107
+ } else if (!job .getStable ()) {
108
+ unstable .add (job );
109
+ } else {
110
+ completelyPassing .add (job );
111
+ }
59
112
}
60
- return failing ;
61
113
}
62
114
63
115
public TreeSet <IViewEntry > getUnclaimedJobs () {
0 commit comments