Fixes jilo-cli conferences search to work with new SQL.
parent
4d4d14dbf0
commit
9a0634cfa7
199
jilo-cli
199
jilo-cli
|
@ -40,26 +40,26 @@ MYSQL_DB=${MYSQL_DB:-$DEFAULT_MYSQL_DB}
|
||||||
###
|
###
|
||||||
|
|
||||||
# DB queries
|
# DB queries
|
||||||
db_stats_conferences_all_template="SELECT * FROM conferences;"
|
db_conferences_all_template="SELECT * FROM conferences;"
|
||||||
db_stats_conferences_name_template="SELECT * FROM conferences WHERE conference_name='%s';"
|
|
||||||
db_stats_conferences_id_template="SELECT * FROM conferences WHERE conference_id='%s';"
|
|
||||||
|
|
||||||
db_stats_conference_events_template="SELECT * FROM conference_events WHERE conference_id='%s';"
|
db_conferences_id_template="SELECT * FROM conferences WHERE conference_id='%s';"
|
||||||
db_stats_participant_events_template="SELECT * FROM participant_events WHERE event_param='%s';"
|
db_conferences_name_template="SELECT * FROM conferences WHERE conference_name='%s';"
|
||||||
|
|
||||||
db_stats_conference_by_id_template="
|
db_participants_id_template="SELECT * FROM participants WHERE endpoint_id='%s';"
|
||||||
SELECT DISTINCT
|
#db_participants_
|
||||||
|
|
||||||
|
db_conference_events_template="SELECT * FROM conference_events WHERE conference_id='%s';"
|
||||||
|
db_participant_events_template="SELECT * FROM participant_events WHERE participant_id='%s';"
|
||||||
|
|
||||||
|
db_conference_by_id_template="
|
||||||
|
SELECT
|
||||||
|
pe.time,
|
||||||
c.conference_id,
|
c.conference_id,
|
||||||
c.conference_name,
|
c.conference_name,
|
||||||
c.conference_host,
|
c.conference_host,
|
||||||
COALESCE(ce.time, pe.time) AS event_time,
|
pe.loglevel,
|
||||||
ce.loglevel AS conference_loglevel,
|
|
||||||
ce.conference_event,
|
|
||||||
ce.conference_param,
|
|
||||||
p.endpoint_id,
|
|
||||||
pe.time AS participant_time,
|
|
||||||
pe.loglevel AS participant_loglevel,
|
|
||||||
pe.event_type,
|
pe.event_type,
|
||||||
|
p.endpoint_id AS participant_id,
|
||||||
pe.event_param
|
pe.event_param
|
||||||
FROM
|
FROM
|
||||||
conferences c
|
conferences c
|
||||||
|
@ -71,22 +71,38 @@ LEFT JOIN
|
||||||
participant_events pe ON p.endpoint_id = pe.participant_id
|
participant_events pe ON p.endpoint_id = pe.participant_id
|
||||||
WHERE
|
WHERE
|
||||||
c.conference_id = '%s'
|
c.conference_id = '%s'
|
||||||
ORDER BY
|
|
||||||
event_time;"
|
|
||||||
|
|
||||||
db_stats_conference_by_name_template="
|
UNION
|
||||||
SELECT DISTINCT
|
|
||||||
|
SELECT
|
||||||
|
ce.time AS event_time,
|
||||||
c.conference_id,
|
c.conference_id,
|
||||||
c.conference_name,
|
c.conference_name,
|
||||||
c.conference_host,
|
c.conference_host,
|
||||||
COALESCE(ce.time, pe.time) AS event_time,
|
ce.loglevel,
|
||||||
ce.loglevel AS conference_loglevel,
|
ce.conference_event AS event_type,
|
||||||
ce.conference_event,
|
NULL AS participant_id,
|
||||||
ce.conference_param,
|
ce.conference_param AS event_param
|
||||||
p.endpoint_id,
|
FROM
|
||||||
pe.time AS participant_time,
|
conferences c
|
||||||
pe.loglevel AS participant_loglevel,
|
LEFT JOIN
|
||||||
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
|
WHERE
|
||||||
|
c.conference_id = '%s'
|
||||||
|
|
||||||
|
ORDER BY
|
||||||
|
pe.time;
|
||||||
|
"
|
||||||
|
|
||||||
|
db_conference_by_name_template="
|
||||||
|
SELECT
|
||||||
|
pe.time,
|
||||||
|
c.conference_id,
|
||||||
|
c.conference_name,
|
||||||
|
c.conference_host,
|
||||||
|
pe.loglevel,
|
||||||
pe.event_type,
|
pe.event_type,
|
||||||
|
p.endpoint_id AS participant_id,
|
||||||
pe.event_param
|
pe.event_param
|
||||||
FROM
|
FROM
|
||||||
conferences c
|
conferences c
|
||||||
|
@ -98,17 +114,37 @@ LEFT JOIN
|
||||||
participant_events pe ON p.endpoint_id = pe.participant_id
|
participant_events pe ON p.endpoint_id = pe.participant_id
|
||||||
WHERE
|
WHERE
|
||||||
c.conference_name = '%s'
|
c.conference_name = '%s'
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
ce.time AS event_time,
|
||||||
|
c.conference_id,
|
||||||
|
c.conference_name,
|
||||||
|
c.conference_host,
|
||||||
|
ce.loglevel,
|
||||||
|
ce.conference_event AS event_type,
|
||||||
|
NULL AS participant_id,
|
||||||
|
ce.conference_param AS event_param
|
||||||
|
FROM
|
||||||
|
conferences c
|
||||||
|
LEFT JOIN
|
||||||
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
|
WHERE
|
||||||
|
c.conference_name = '%s'
|
||||||
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
event_time;"
|
pe.time;
|
||||||
|
"
|
||||||
|
|
||||||
db_stats_conferences_time_template="SELECT * FROM conferences WHERE start >= '%s' AND end <= '%s';"
|
#db_conferences_time_template="SELECT * FROM conferences WHERE start >= '%s' AND end <= '%s';"
|
||||||
|
#
|
||||||
db_stats_participants_all_template="SELECT * FROM participants;"
|
#db_participants_all_template="SELECT * FROM participants;"
|
||||||
db_stats_participants_conference_template="SELECT * FROM participants WHERE conference_id='%s';"
|
#db_participants_conference_template="SELECT * FROM participants WHERE conference_id='%s';"
|
||||||
db_stats_participants_event_template="SELECT * FROM participants WHERE event_type LIKE '%%%s%%';"
|
#db_participants_event_template="SELECT * FROM participants WHERE event_type LIKE '%%%s%%';"
|
||||||
db_stats_participants_endpoint_template="SELECT * FROM participants WHERE endpoint_id='%s';"
|
#db_participants_endpoint_template="SELECT * FROM participants WHERE endpoint_id='%s';"
|
||||||
db_stats_participants_statsid_template="SELECT * FROM participants WHERE stats_id LIKE '%%%s%%';"
|
#db_participants_statsid_template="SELECT * FROM participants WHERE stats_id LIKE '%%%s%%';"
|
||||||
db_stats_participants_ip_template="SELECT * FROM participants WHERE participant_ip='%s';"
|
#db_participants_ip_template="SELECT * FROM participants WHERE participant_ip='%s';"
|
||||||
|
|
||||||
|
|
||||||
help="Usage:
|
help="Usage:
|
||||||
|
@ -291,53 +327,42 @@ case "$cmd" in
|
||||||
# the argument to "--conference" can be either ID or name
|
# the argument to "--conference" can be either ID or name
|
||||||
if [[ -n "$conference_arg" ]]; then
|
if [[ -n "$conference_arg" ]]; then
|
||||||
|
|
||||||
db_stats_conferences_id=$(printf "$db_stats_conferences_id_template" "$conference_arg")
|
db_conferences_id=$(printf "$db_conferences_id_template" "$conference_arg")
|
||||||
stats_conferences_id=$(db_query "$db_stats_conferences_id")
|
conferences_id=$(db_query "$db_conferences_id")
|
||||||
|
|
||||||
db_stats_conferences_name=$(printf "$db_stats_conferences_name_template" "$conference_arg")
|
db_conferences_name=$(printf "$db_conferences_name_template" "$conference_arg")
|
||||||
stats_conferences_name=$(db_query "$db_stats_conferences_name")
|
conferences_name=$(db_query "$db_conferences_name")
|
||||||
|
|
||||||
# we check if the argument to "--conference" is a conference ID
|
# we check if the argument to "--conference" is a conference ID
|
||||||
# conference ID is unique, so we show that conference
|
# conference ID is unique, so we show that conference
|
||||||
if [[ -n "$stats_conferences_id" ]]; then
|
if [[ -n "$conferences_id" ]]; then
|
||||||
db_stats_conference=$(printf "$db_stats_conference_by_id_template" "$conference_arg")
|
db_conference=$(printf "$db_conference_by_id_template" "$conference_arg" "$conference_arg")
|
||||||
mapfile -t stats_conference_array < <(db_query "$db_stats_conference")
|
mapfile -t conference_array < <(db_query "$db_conference")
|
||||||
|
# prepare the header
|
||||||
current_conference=""
|
output="time\tconf ID\tconf name\tconf host\tloglevel\tparticipant ID\tevent\tparameter\n"
|
||||||
for row in "${stats_conference_array[@]}"; do
|
# prepare the formatted rows
|
||||||
IFS='|' read -r conference_id conference_name conference_host conference_time loglevel conference_event conference_param endpoint_id participant_time loglevel event_type event_param <<< "$row"
|
for row in "${conference_array[@]}"; do
|
||||||
|
IFS='|' read -r time conference_id conference_name conference_host loglevel event_type participant_id event_param <<< "$row"
|
||||||
if [[ -z "$current_conference" ]]; then
|
output+="$time\t$conference_id\t$conference_name\t$conference_host\t$loglevel\t$participant_id\t$event_type\t$event_param\n"
|
||||||
current_conference="$conference_name"
|
|
||||||
echo "$conference_time | $conference_id | $conference_name | $conference_host | $loglevel | Conference created"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$conference_event" ]]; then
|
|
||||||
echo "$participant_time | $conference_id | $conference_name | $conference_host | $loglevel | $endpoint_id | $event_type | $event_param"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "$conference_time | $conference_id | $conference_name | $conference_host | $loglevel | Conference Ended"
|
# output
|
||||||
|
echo -e "$output" | column -t -s $'\t'
|
||||||
|
|
||||||
# then we check if the argument to "--conference" is a conference name
|
# then we check if the argument to "--conference" is a conference name
|
||||||
# if so, we show all matching conferences (conference names are not unique)
|
# if so, we show all matching conferences (conference names are not unique)
|
||||||
elif [[ -n "$stats_conferences_name" ]]; then
|
elif [[ -n "$conferences_name" ]]; then
|
||||||
db_stats_conference=$(printf "$db_stats_conference_by_name_template" "$conference_arg")
|
db_conference=$(printf "$db_conference_by_name_template" "$conference_arg" "$conference_arg")
|
||||||
mapfile -t stats_conference_array < <(db_query "$db_stats_conference")
|
mapfile -t conference_array < <(db_query "$db_conference")
|
||||||
|
|
||||||
current_conference=""
|
# prepare the header
|
||||||
for row in "${stats_conference_array[@]}"; do
|
output="time\tconf ID\tconf name\tconf host\tloglevel\tparticipant ID\tevent\tparameter\n"
|
||||||
IFS='|' read -r conference_id conference_name conference_host conference_time loglevel conference_event conference_param endpoint_id participant_time loglevel event_type event_param <<< "$row"
|
# prepare the formatted rows
|
||||||
|
for row in "${conference_array[@]}"; do
|
||||||
if [[ -z "$current_conference" ]]; then
|
IFS='|' read -r time conference_id conference_name conference_host loglevel event_type participant_id event_param <<< "$row"
|
||||||
current_conference="$conference_name"
|
output+="$time\t$conference_id\t$conference_name\t$conference_host\t$loglevel\t$participant_id\t$event_type\t$event_param\n"
|
||||||
echo "$conference_time | $conference_id | $conference_name | $conference_host | $loglevel | Conference created"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$conference_event" ]]; then
|
|
||||||
echo "$participant_time | $conference_id | $conference_name | $conference_host | $loglevel | $endpoint_id | $event_type | $event_param"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "$conference_time | $conference_id | $conference_name | $conference_host | $loglevel | Conference Ended"
|
# output
|
||||||
|
echo -e "$output" | column -t -s $'\t'
|
||||||
|
|
||||||
# nothing found for neither conference ID or name
|
# nothing found for neither conference ID or name
|
||||||
else
|
else
|
||||||
|
@ -346,36 +371,36 @@ case "$cmd" in
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
# if no argument is given, we show all the conferences
|
# if no argument is given, we show all the conferences
|
||||||
db_stats_conferences_all=$(printf "$db_stats_conferences_all_template")
|
db_conferences_all=$(printf "$db_conferences_all_template")
|
||||||
db_query "$db_stats_conferences_all"
|
db_query "$db_conferences_all"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--participant)
|
--participant)
|
||||||
if [[ -n "$participant_arg" ]]; then
|
if [[ -n "$participant_arg" ]]; then
|
||||||
db_stats_participants_conference=$(printf "$db_stats_participants_conference_template" "$participant_arg")
|
db_participants_conference=$(printf "$db_participants_conference_template" "$participant_arg")
|
||||||
db_query "$db_stats_participants_conference"
|
db_query "$db_participants_conference"
|
||||||
db_stats_participants_event=$(printf "$db_stats_participants_event_template" "$participant_arg")
|
db_participants_event=$(printf "$db_participants_event_template" "$participant_arg")
|
||||||
db_query "$db_stats_participants_event"
|
db_query "$db_participants_event"
|
||||||
db_stats_participants_endpoint=$(printf "$db_stats_participants_endpoint_template" "$participant_arg")
|
db_participants_endpoint=$(printf "$db_participants_endpoint_template" "$participant_arg")
|
||||||
db_query "$db_stats_participants_endpoint"
|
db_query "$db_participants_endpoint"
|
||||||
db_stats_participants_statsid=$(printf "$db_stats_participants_statsid_template" "$participant_arg")
|
db_participants_statsid=$(printf "$db_participants_statsid_template" "$participant_arg")
|
||||||
db_query "$db_stats_participants_statsid"
|
db_query "$db_participants_statsid"
|
||||||
db_stats_participants_ip=$(printf "$db_stats_participants_ip_template" "$participant_arg")
|
db_participants_ip=$(printf "$db_participants_ip_template" "$participant_arg")
|
||||||
db_query "$db_stats_participants_ip"
|
db_query "$db_participants_ip"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
db_stats_participants_all=$(printf "$db_stats_participants_all_template" )
|
db_participants_all=$(printf "$db_participants_all_template" )
|
||||||
db_query "$db_stats_participants_all"
|
db_query "$db_participants_all"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--time)
|
--time)
|
||||||
if [[ "$time_range_specified" == true ]]; then
|
if [[ "$time_range_specified" == true ]]; then
|
||||||
db_stats_conferences_time=$(printf "$db_stats_conferences_time_template" "$from_time" "$until_time")
|
db_conferences_time=$(printf "$db_conferences_time_template" "$from_time" "$until_time")
|
||||||
db_query "$db_stats_conferences_time"
|
db_query "$db_conferences_time"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue