database/print-stream-summary.sh in message-db-2.1.6 vs database/print-stream-summary.sh in message-db-3.0.0
- old
+ new
@@ -28,17 +28,21 @@
else
stream_name=$STREAM_NAME
echo "Stream name is: $STREAM_NAME"
fi
+function run_psql_command {
+ psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
+}
+
echo
echo "Stream Summary"
echo "= = ="
echo
if [ -z $stream_name ]; then
- psql $database -U $user -P pager=off -c "SELECT * FROM stream_summary ORDER BY message_count DESC;"
- psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages;"
+ run_psql_command "SELECT * FROM stream_summary ORDER BY message_count DESC;"
+ run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
else
- psql $database -U $user -P pager=off -c "SELECT * FROM stream_summary WHERE stream_name LIKE '%$stream_name%' ORDER BY message_count DESC;"
- psql $database -U $user -P pager=off -c "SELECT COUNT(*) AS total_count FROM messages WHERE stream_name LIKE '%$stream_name%';"
+ run_psql_command "SELECT * FROM stream_summary WHERE stream_name LIKE '%$stream_name%' ORDER BY message_count DESC;"
+ run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE stream_name LIKE '%$stream_name%';"
fi