Updates jilo-cli to filter conferences by time period.
parent
da0011869d
commit
d5a9a74879
|
@ -15,6 +15,9 @@ All notable changes to this project will be documented in this file.
|
||||||
### Added
|
### Added
|
||||||
- Initial changelog following the keepachangelog.com format
|
- Initial changelog following the keepachangelog.com format
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated the way jilo-cli handles multiple options, added filtering conferences by time period
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 0.1 - 2024-06-12
|
## 0.1 - 2024-06-12
|
||||||
|
|
74
jilo-cli
74
jilo-cli
|
@ -68,6 +68,9 @@ JOIN (
|
||||||
GROUP BY
|
GROUP BY
|
||||||
conference_name
|
conference_name
|
||||||
) AS name_counts ON c.conference_name = name_counts.conference_name
|
) AS name_counts ON c.conference_name = name_counts.conference_name
|
||||||
|
JOIN
|
||||||
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
|
WHERE (ce.time >= '%s' AND ce.time <= '%s')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
c.id;"
|
c.id;"
|
||||||
db_conferences_id_template="SELECT * FROM conferences WHERE conference_id='%s';"
|
db_conferences_id_template="SELECT * FROM conferences WHERE conference_id='%s';"
|
||||||
|
@ -93,6 +96,7 @@ 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'
|
||||||
|
AND (pe.time >= '%s' AND pe.time <= '%s')
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
|
@ -111,6 +115,7 @@ LEFT JOIN
|
||||||
conference_events ce ON c.conference_id = ce.conference_id
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
WHERE
|
WHERE
|
||||||
c.conference_id = '%s'
|
c.conference_id = '%s'
|
||||||
|
AND (event_time >= '%s' AND event_time <= '%s')
|
||||||
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time;"
|
pe.time;"
|
||||||
|
@ -134,6 +139,7 @@ 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'
|
||||||
|
AND (pe.time >= '%s' AND pe.time <= '%s')
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
|
@ -152,6 +158,7 @@ LEFT JOIN
|
||||||
conference_events ce ON c.conference_id = ce.conference_id
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
WHERE
|
WHERE
|
||||||
c.conference_name = '%s'
|
c.conference_name = '%s'
|
||||||
|
AND (event_time >= '%s' AND event_time <= '%s')
|
||||||
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time;"
|
pe.time;"
|
||||||
|
@ -516,15 +523,19 @@ parse_time_range() {
|
||||||
|
|
||||||
cmd=""
|
cmd=""
|
||||||
conference_arg=""
|
conference_arg=""
|
||||||
|
conference_option=false
|
||||||
participant_arg=""
|
participant_arg=""
|
||||||
from_time=""
|
participant_option=false
|
||||||
until_time=""
|
from_time="0000-00-00"
|
||||||
|
until_time="9999-12-31"
|
||||||
|
time_option=false
|
||||||
time_range_specified=false
|
time_range_specified=false
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-c | --conference )
|
-c | --conference )
|
||||||
cmd="--conference"
|
cmd="--conference"
|
||||||
|
conference_option=true
|
||||||
if [[ -n "$2" && "$2" != -* ]]; then
|
if [[ -n "$2" && "$2" != -* ]]; then
|
||||||
conference_arg="$2"
|
conference_arg="$2"
|
||||||
shift 2
|
shift 2
|
||||||
|
@ -534,6 +545,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
;;
|
;;
|
||||||
-p | --participant)
|
-p | --participant)
|
||||||
cmd="--participant"
|
cmd="--participant"
|
||||||
|
participant_option=true
|
||||||
if [[ -n "$2" && "$2" != -* ]]; then
|
if [[ -n "$2" && "$2" != -* ]]; then
|
||||||
participant_arg="$2"
|
participant_arg="$2"
|
||||||
shift 2
|
shift 2
|
||||||
|
@ -543,7 +555,9 @@ while [[ $# -gt 0 ]]; do
|
||||||
;;
|
;;
|
||||||
-t | --time)
|
-t | --time)
|
||||||
cmd="--time"
|
cmd="--time"
|
||||||
|
time_option=true
|
||||||
if [[ -n "$2" && "$2" != -* ]]; then
|
if [[ -n "$2" && "$2" != -* ]]; then
|
||||||
|
time_arg="$2"
|
||||||
parse_time_range "$2"
|
parse_time_range "$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
|
@ -551,6 +565,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
-v | --verbose)
|
||||||
|
verbose=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
echo -e "$help"
|
echo -e "$help"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -567,27 +585,24 @@ while [[ $# -gt 0 ]]; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
case "$cmd" in
|
if [[ "$conference_option" == true ]]; then
|
||||||
|
|
||||||
--conference)
|
|
||||||
# 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_conferences_id=$(printf "$db_conferences_id_template" "$conference_arg")
|
# check for conferences match within a time period (or all if not period given)
|
||||||
conferences_id=$(db_query "$db_conferences_id")
|
db_conferences_id=$(printf "$db_conference_by_id_template" "$conference_arg" "$from_time" "$until_time" "$conference_arg" "$from_time" "$until_time")
|
||||||
|
mapfile -t conferences_id < <(db_query "$db_conferences_id")
|
||||||
db_conferences_name=$(printf "$db_conferences_name_template" "$conference_arg")
|
db_conferences_name=$(printf "$db_conference_by_name_template" "$conference_arg" "$from_time" "$until_time" "$conference_arg" "$from_time" "$until_time")
|
||||||
conferences_name=$(db_query "$db_conferences_name")
|
mapfile -t 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 "$conferences_id" ]]; then
|
if [[ "${#conferences_id[@]}" -gt 0 ]]; then
|
||||||
db_conference=$(printf "$db_conference_by_id_template" "$conference_arg" "$conference_arg")
|
|
||||||
mapfile -t conference_array < <(db_query "$db_conference")
|
|
||||||
# prepare the header
|
# prepare the header
|
||||||
output="time\tconference ID\tconference name\tconference host\tloglevel\tparticipant ID\tevent\tparameter\n"
|
output="time\tconference ID\tconference name\tconference host\tloglevel\tparticipant ID\tevent\tparameter\n"
|
||||||
# prepare the formatted rows
|
# prepare the formatted rows
|
||||||
for row in "${conference_array[@]}"; do
|
for row in "${conferences_id[@]}"; do
|
||||||
IFS='|' read -r time conference_id conference_name conference_host loglevel event_type participant_id event_param <<< "$row"
|
IFS='|' read -r time conference_id conference_name conference_host loglevel event_type participant_id event_param <<< "$row"
|
||||||
output+="$time\t$IMPORTANT_TEXT$conference_id$NORMAL_TEXT\t$conference_name\t$conference_host\t$loglevel\t$participant_id\t$event_type\t$event_param\n"
|
output+="$time\t$IMPORTANT_TEXT$conference_id$NORMAL_TEXT\t$conference_name\t$conference_host\t$loglevel\t$participant_id\t$event_type\t$event_param\n"
|
||||||
done
|
done
|
||||||
|
@ -596,14 +611,11 @@ case "$cmd" in
|
||||||
|
|
||||||
# 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 "$conferences_name" ]]; then
|
elif [[ "${#conferences_name[@]}" -gt 0 ]]; then
|
||||||
db_conference=$(printf "$db_conference_by_name_template" "$conference_arg" "$conference_arg")
|
|
||||||
mapfile -t conference_array < <(db_query "$db_conference")
|
|
||||||
|
|
||||||
# prepare the header
|
# prepare the header
|
||||||
output="time\tconf ID\tconf name\tconf host\tloglevel\tparticipant ID\tevent\tparameter\n"
|
output="time\tconf ID\tconf name\tconf host\tloglevel\tparticipant ID\tevent\tparameter\n"
|
||||||
# prepare the formatted rows
|
# prepare the formatted rows
|
||||||
for row in "${conference_array[@]}"; do
|
for row in "${conferences_name[@]}"; do
|
||||||
IFS='|' read -r time conference_id conference_name conference_host loglevel event_type participant_id event_param <<< "$row"
|
IFS='|' read -r time conference_id conference_name conference_host loglevel event_type participant_id event_param <<< "$row"
|
||||||
output+="$time\t$conference_id\t$IMPORTANT_TEXT$conference_name$NORMAL_TEXT\t$conference_host\t$loglevel\t$participant_id\t$event_type\t$event_param\n"
|
output+="$time\t$conference_id\t$IMPORTANT_TEXT$conference_name$NORMAL_TEXT\t$conference_host\t$loglevel\t$participant_id\t$event_type\t$event_param\n"
|
||||||
done
|
done
|
||||||
|
@ -613,11 +625,18 @@ case "$cmd" in
|
||||||
# nothing found for neither conference ID or name
|
# nothing found for neither conference ID or name
|
||||||
else
|
else
|
||||||
echo "No match found for \"$conference_arg\""
|
echo "No match found for \"$conference_arg\""
|
||||||
|
if [[ "$time_range_specified" == true ]]; then
|
||||||
|
echo "and time period $from_time - $until_time"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
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
|
||||||
mapfile -t conference_array < <(db_query "$db_conferences_all_formatted_template")
|
db_conferences_all=$(printf "$db_conferences_all_formatted_template" "$from_time" "$until_time")
|
||||||
|
mapfile -t conference_array < <(db_query "$db_conferences_all")
|
||||||
|
|
||||||
|
# we only format the outrput if there are conferences to show
|
||||||
|
if [[ "${#conference_array[@]}" -gt 0 ]]; then
|
||||||
# prepare the header
|
# prepare the header
|
||||||
output="component\tconference ID\tconference name\tname count\tconference host\n"
|
output="component\tconference ID\tconference name\tname count\tconference host\n"
|
||||||
# prepare the formatted rows
|
# prepare the formatted rows
|
||||||
|
@ -627,8 +646,25 @@ case "$cmd" in
|
||||||
done
|
done
|
||||||
# output
|
# output
|
||||||
echo -e "$output" | column -t -s $'\t'
|
echo -e "$output" | column -t -s $'\t'
|
||||||
|
else
|
||||||
|
echo -n "No conferences found"
|
||||||
|
if [[ "$time_range_specified" == true ]]; then
|
||||||
|
echo -n " for the time period \"$from_time - $until_time\""
|
||||||
|
fi
|
||||||
|
echo "."
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
elif [[ "$participant_option" == true ]]; then
|
||||||
|
echo 'hi'
|
||||||
|
elif [[ "$time_option" == true ]]; then
|
||||||
|
echo 'hi'
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
|
||||||
|
--conference)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--participant)
|
--participant)
|
||||||
|
|
Loading…
Reference in New Issue