Skip to content

Commit

Permalink
more checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vdesabou committed Feb 1, 2024
1 parent 0ebdb23 commit 7d8cb6b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
23 changes: 13 additions & 10 deletions scripts/cli/playground
Original file line number Diff line number Diff line change
Expand Up @@ -18877,16 +18877,19 @@ playground_connector_show_lag_command() {
compare_line="🏁"
fi

# calculate the percentage of lag
percentage=$((100 * lag / end_offset))
inverse_percentage=$((100 - percentage))

# create the progress bar
bar_length=20
filled_length=$((percentage * bar_length / 100))
empty_length=$((bar_length - filled_length))
bar=$(printf "%${empty_length}s" | tr ' ' '🔹')
bar+=$(printf "%${filled_length}s" | tr ' ' '💠')
if [[ "$end_offset" =~ ^[0-9]+$ ]] && [[ "$end_offset" =~ ^[0-9]+$ ]] && [ $end_offset != 0 ]
then
# calculate the percentage of lag
percentage=$((100 * lag / end_offset))
inverse_percentage=$((100 - percentage))

# create the progress bar
bar_length=20
filled_length=$((percentage * bar_length / 100))
empty_length=$((bar_length - filled_length))
bar=$(printf "%${empty_length}s" | tr ' ' '🔹')
bar+=$(printf "%${filled_length}s" | tr ' ' '💠')
fi

prev_lags["${topic}_${partition}"]=$lag
if [ "$compare_line" != "" ]
Expand Down
23 changes: 13 additions & 10 deletions scripts/cli/src/commands/connector/show-lag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,19 @@ function show_output () {
compare_line="🏁"
fi

# calculate the percentage of lag
percentage=$((100 * lag / end_offset))
inverse_percentage=$((100 - percentage))

# create the progress bar
bar_length=20
filled_length=$((percentage * bar_length / 100))
empty_length=$((bar_length - filled_length))
bar=$(printf "%${empty_length}s" | tr ' ' '🔹')
bar+=$(printf "%${filled_length}s" | tr ' ' '💠')
if [[ "$end_offset" =~ ^[0-9]+$ ]] && [[ "$end_offset" =~ ^[0-9]+$ ]] && [ $end_offset != 0 ]
then
# calculate the percentage of lag
percentage=$((100 * lag / end_offset))
inverse_percentage=$((100 - percentage))

# create the progress bar
bar_length=20
filled_length=$((percentage * bar_length / 100))
empty_length=$((bar_length - filled_length))
bar=$(printf "%${empty_length}s" | tr ' ' '🔹')
bar+=$(printf "%${filled_length}s" | tr ' ' '💠')
fi

prev_lags["${topic}_${partition}"]=$lag
if [ "$compare_line" != "" ]
Expand Down

0 comments on commit 7d8cb6b

Please sign in to comment.