@@ -224,7 +224,7 @@ jobs:
224224 echo "Checking stats, attempt $i..."
225225
226226 stats_err=$(mktemp)
227- stats=$(timeout 5 ./occ context_chat:stats 2>"$stats_err")
227+ stats=$(timeout 5 ./occ context_chat:stats --json 2>"$stats_err")
228228 stats_exit=$?
229229 echo "Stats output:"
230230 echo "$stats"
@@ -243,41 +243,25 @@ jobs:
243243 fi
244244
245245 # Extract Total eligible files
246- total_files=$(echo "$stats" | grep -oP 'Total eligible files:\s*\K\d+ ' || echo "")
246+ total_files=$(echo "$stats" | jq '.eligible_files_count ' || echo "")
247247
248248 # Extract Indexed documents count (files__default)
249- indexed_count=$(echo "$stats" | grep -oP "'files__default'\s*=>\s*\K\d+" || echo "")
250-
251- # Validate parsed values
252- if [ -z "$total_files" ] || [ -z "$indexed_count" ]; then
253- echo "Error: Could not parse stats output properly"
254- if echo "$stats" | grep -q "Indexed documents:"; then
255- echo " Indexed documents section found but could not extract count"
256- fi
257- sleep 10
258- continue
259- fi
249+ indexed_count=$(echo "$stats" | jq '.queued_documents_counts.files__default' || echo "")
260250
261251 echo "Total eligible files: $total_files"
262252 echo "Indexed documents (files__default): $indexed_count"
263253
264- # Calculate absolute difference
265254 diff=$((total_files - indexed_count))
266- if [ $diff -lt 0 ]; then
267- diff=$((-diff))
268- fi
269-
270- # Calculate 2% threshold using bc for floating point support
271- threshold=$(echo "scale=4; $total_files * 0.02" | bc)
255+ threshold=$((total_files * 2 / 100))
272256
273257 # Check if difference is within tolerance
274- if (( $(echo "$ diff <= $threshold" | bc -l) )) ; then
258+ if [ $ diff -le $threshold ] ; then
275259 echo "Indexing within 2% tolerance (diff=$diff, threshold=$threshold)"
276260 success=1
277261 break
278262 else
279- pct =$(echo "scale=2; ($ diff / $total_files) * 100" | bc )
280- echo "Outside 2% tolerance: diff=$diff (${pct }%), threshold=$threshold"
263+ progress =$(( diff * 100 / total_files) )
264+ echo "Outside 2% tolerance: diff=$diff (${progress }%), threshold=$threshold"
281265 fi
282266
283267 # Check if backend is still alive
@@ -293,6 +277,7 @@ jobs:
293277 echo "::endgroup::"
294278
295279 ./occ context_chat:stats
280+ ./occ context_chat:stats --json
296281
297282 if [ $success -ne 1 ]; then
298283 echo "Max attempts reached"
0 commit comments