feat: Use the last known ID as a checkpoint for further iterations
This commit is contained in:
parent
48c38ea62d
commit
c65c1c2719
1 changed files with 4 additions and 1 deletions
|
@ -14,6 +14,8 @@ iteration=0
|
||||||
n=1
|
n=1
|
||||||
#Number of entries processed
|
#Number of entries processed
|
||||||
nx=0
|
nx=0
|
||||||
|
#Last known ID to have been successfully processed
|
||||||
|
lastid=0
|
||||||
#Generate an index to make searches faster
|
#Generate an index to make searches faster
|
||||||
((indexlength=37+${#url}))
|
((indexlength=37+${#url}))
|
||||||
echo "Generating photo index..."
|
echo "Generating photo index..."
|
||||||
|
@ -27,7 +29,7 @@ do
|
||||||
iteration=$(("$iteration" + 1))
|
iteration=$(("$iteration" + 1))
|
||||||
n=0
|
n=0
|
||||||
nx=0
|
nx=0
|
||||||
dblist=$(mariadb $db -B -N -q -e "select id, photo, thumb, micro from contact where photo like 'https:\/\/$url/avatar/%' order by id")
|
dblist=$(mariadb $db -B -N -q -e "select id, photo, thumb, micro from contact where id > $lastid and photo like 'https:\/\/$url/avatar/%' order by id")
|
||||||
m=$(echo "$dblist" | wc -l)
|
m=$(echo "$dblist" | wc -l)
|
||||||
echo "$dblist" | while read -r id photo thumb micro
|
echo "$dblist" | while read -r id photo thumb micro
|
||||||
do
|
do
|
||||||
|
@ -69,6 +71,7 @@ do
|
||||||
fi
|
fi
|
||||||
n=$(( n + 1 ))
|
n=$(( n + 1 ))
|
||||||
fi
|
fi
|
||||||
|
lastid="${id}"
|
||||||
printf "\rIteration %s\tPhotos: %s\tEntry %s/%s " "$iteration" "$n" "$nx" "$m"
|
printf "\rIteration %s\tPhotos: %s\tEntry %s/%s " "$iteration" "$n" "$nx" "$m"
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Add table
Reference in a new issue