Showing 1 changed files with 5 additions and 2 deletions
+5 -2
analyse-votes-AN
... ...
@@ -47,6 +47,8 @@ function update_database () {
47 47
     test "$no_db_update" = $true_flag && return
48 48
     tempfile="/dev/shm/scrutin.$$"
49 49
     progress=0
50
+    first_=$first
51
+    first=$(sqlite3 "$in_ram_database" <<< "select count(num) from scrutins")
50 52
     if test ${first:-0} -lt $last; then
51 53
         echo "récupération des scrutins n°$((${first:-0}+1)) à n°$last dans "$database" (à conserver autant que possible)" >&2
52 54
 
... ...
@@ -124,6 +126,7 @@ function update_database () {
124 126
         done
125 127
         rm -f "$url_database" "$tempfile"
126 128
     fi
129
+    first=$first_
127 130
 }
128 131
 
129 132
 function write_comparaison () {
... ...
@@ -458,12 +461,12 @@ if test "$periode" = $true_flag; then
458 461
     last=$(sqlite3 "$in_ram_database" <<< "select num from scrutins where date like '% du ${periode_value#*:}' order by num asc" | tail -1)
459 462
     test -z "$first" && echo "date de début inconnue: ${periode_value#*:}" >&2 && rm -f $in_ram_database && exit 1
460 463
     test -z "$last" && echo "date de fin inconnue: ${periode_value%:*}" >&2 && rm -f $in_ram_database && exit 1
461
-else
464
+elif test "$dossier" != $true_flag; then
462 465
     test -z "$last" && last=$(wget -qO- 'http://www2.assemblee-nationale.fr/scrutins/liste/(legislature)/15/(type)/TOUS/(idDossier)/TOUS' \
463 466
             | sed -rn 's,^.*<td class="denom">(.+)</td>.*$,\1,p' \
464 467
             | head -1)
465 468
 
466
-    test -z "$first" && first=$(sqlite3 "$in_ram_database" <<< "select count(num) from scrutins")
469
+    test -z "$first" && first=1
467 470
 fi
468 471
 
469 472
 if test "$liste_dossiers" = $true_flag; then