Showing 1 changed files with 9 additions and 6 deletions
+9 -6
analyse-votes-AN
... ...
@@ -286,16 +286,17 @@ EOcontent
286 286
             done
287 287
         echo '</table:table-row>' >> "$content"
288 288
 
289
-        let line++
290
-
291
-        if test $((($scrutin*100)/$last)) -ne $progress; then
292
-            progress=$((($scrutin*100)/$last))
293
-            if test $(($progress % ${generation_progress:-5})) -eq 0; then
289
+        if test $(( ($line * 100) / ${qty:-$last} )) -ne $progress; then
290
+            progress=$(( ($line * 100) / ${qty:-$last} ))
291
+            if test $(( $progress % ${generation_progress:-5} )) -eq 0; then
294 292
                 now=$(date +%s)
295 293
                 delta=$(( $now - $begin ))
296
-                echo $progress%, ETA: $(date +%H:%M:%S -d "$(($delta * ($last - $scrutin) / $scrutin)) seconds")
294
+                echo $progress%, ETA: $(date +%H:%M:%S -d "$(( $delta * (${qty:-$last} - $line) / $line )) seconds")
297 295
             fi
298 296
         fi
297
+
298
+        let line++
299
+
299 300
     done
300 301
     echo
301 302
 
... ...
@@ -510,12 +511,14 @@ if test "$dossier" = $true_flag; then
510 511
         select dossier in $(sqlite3 "$in_ram_database" <<< "select url from url" | sed 's,^.*/dossiers/,,; s/_/ /g; s/.asp$//'); do
511 512
             if test -n "$dossier"; then
512 513
                 seq="sqlite3 \"$in_ram_database\" <<< \"select num from scrutins inner join url on url.id = scrutins.url where url.url like '%/dossiers/${dossier// /_}%' order by num asc\""
514
+                qty=$(sqlite3 "$in_ram_database" <<< "select count(num) from scrutins inner join url on url.id = scrutins.url where url.url like '%/dossiers/${dossier// /_}%' order by num asc")
513 515
                 break
514 516
             fi
515 517
         done
516 518
         IFS=$IFS_
517 519
     else
518 520
         seq="sqlite3 \"$in_ram_database\" <<< \"select num from scrutins inner join url on url.id = scrutins.url where url.id is $dossier_value order by num asc\""
521
+        qty=$(sqlite3 "$in_ram_database" <<< "select count(num) from scrutins inner join url on url.id = scrutins.url where url.id is $dossier_value order by num asc")
519 522
         dossier=$(sqlite3 "$in_ram_database" <<< "select url from url where id is $dossier_value" | sed 's,^.*/dossiers/,,; s/_/ /g; s/.asp$//')
520 523
     fi
521 524
 fi