2727import hudson .model .Run ;
2828import hudson .util .RunList ;
2929import java .util .ArrayList ;
30+ import java .util .Iterator ;
3031import java .util .List ;
3132import jenkins .util .ProgressiveRendering ;
3233import net .sf .json .JSON ;
@@ -46,7 +47,9 @@ public abstract class RunListProgressiveRendering extends ProgressiveRendering {
4647 * The first increment will be sized as if this many runs will be in the total,
4748 * but then like Zeno’s paradox we will never seem to finish until we actually do.
4849 */
49- private static final double MAX_LIKELY_RUNS = 20 ;
50+ private static final double MAX_LIKELY_RUNS = 20 ; // if (MAX_LIKELY_RUNS / 2) runs are processed, progress is 0.5
51+ private static final int RUN_LIMIT = 10_000 ; // Limit is need because UI doesn't have a pagination
52+
5053 private final List <JSONObject > results = new ArrayList <>();
5154 private Iterable <? extends Run <?, ?>> builds ;
5255
@@ -56,18 +59,17 @@ public void setBuilds(Iterable<? extends Run<?, ?>> builds) {
5659 }
5760
5861 @ Override protected void compute () throws Exception {
59- double decay = 1 ;
60- for (Run <?, ?> build : builds ) {
61- if (canceled ()) {
62- return ;
63- }
62+ int processed = 0 ;
63+ Iterator <? extends Run <?, ?>> iter = builds .iterator ();
64+ while (!canceled () && iter .hasNext () && processed < RUN_LIMIT ) {
65+ Run <?, ?> build = iter .next ();
6466 JSONObject element = new JSONObject ();
6567 calculate (build , element );
6668 synchronized (this ) {
6769 results .add (element );
6870 }
69- decay *= 1 - 1 / MAX_LIKELY_RUNS ;
70- progress (1 - decay );
71+ processed ++ ;
72+ progress (processed / ( processed + MAX_LIKELY_RUNS / 2.0 ) );
7173 }
7274 }
7375
0 commit comments