in reply to Re^2: Stats for super search look buggy
in thread Stats for super search look buggy

Well, the percentage calculator could be presumably changed to something like
```use constant jump => 9866219;
my \$delta = \$last_node_in_search_range - \$first_node_in_search_range;
\$delta -= jump if \$delta > jump;
my \$percent = 100 * \$delta / (\$most_recent_node_id - jump);

Replies are listed 'Best First'.
Re^4: Stats for super search look buggy
by jdporter (Canon) on May 10, 2021 at 03:40 UTC

Right, but I don't think that the delta merely being larger than the gap is a sufficient test; we should check whether the search actually spans the gap:

```\$delta -= jump
if  \$first_node_in_search_range <= 1233781
&&   \$last_node_in_search_range >= 11100000;
Diminishing the bigger a ° value by the gap-distance, if it exceeds the threshold, is sufficient.

```\$bigger_node_in_search_range -= \$jump if
\$bigger_node_in_search_range > 1233781;

```for (\$node_min, \$node_max) {
\$_ -= \$jump if  \$_ > 1233781;
}

Calculate percentage then

##### update

°) sorry, both could have jumped.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

that looks more complicated to me. and less easily understood for a future maintainer. :-)

Good point. As of today, I don't see a way that the delta would be over 9 million if it wasn't crossing the gap without another 9million posts or another gap, but might as well future-proof it ... and just because I don't see something doesn't mean it doesn't exist.

My reply was a rather off-the-cuff, first-level approximation of how I thought I might solve it, rather than a fully fleshed-out solution, with implications and edge cases considered. Also, I also realized that my reply could have come across as "why haven't you come up with this", which isn't what I intended; rather, I meant something more like "but at least the fix shouldn't be too difficult to come up with (famous last words), something like /this/".

Re^4: Stats for super search look buggy
by LanX (Sage) on May 08, 2021 at 23:43 UTC
I've already identified the code in question, but it's a little more complicated.

Furthermore there is also the "remaining" part, and the search could go backwards.

Interested pmdevs can submit patches here

``` 511:           . qq[ (searched ] . sprintf( "%.2f",
512:               100*( abs(\$n0-\$start)+1 ) / \$lastNode
513:             ) . qq[% of DB).</div><br />\n<div class="ss-criteri
+a-summary">\n];

and

``` 569:         } else {
570:             my( \$min, \$max )= \$oldFirst ? ( \$n0, \$lastNode ) : (
+ 1, \$n0 );
571:             my \$pct= sprintf "%.2f%%", 100*(\$max-\$min+1)/\$lastNo
+de;
572:             if(  1 == \$doSearch  ) {
573:                 \$html .= qq[Press ]
574:                   . \$q->submit( "nx", "Next >" )
575:                   . qq[ to <b>continue</b> searching remaining \$
+pct of DB.];
576:             } else {