Orgas graph: improvements (tests @begining + cosmetic improvements + data)
This commit is contained in:
parent
3406e4d596
commit
ffbaeb5dc6
53
orgas/gen.sh
53
orgas/gen.sh
@ -3,11 +3,24 @@
|
|||||||
# Generate a dot file to create graph of RERO-ils data (orga, lib and users)
|
# Generate a dot file to create graph of RERO-ils data (orga, lib and users)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# CONFIG
|
||||||
RERO_DIR="${HOME}/projets/rero/rero-ils"
|
RERO_DIR="${HOME}/projets/rero/rero-ils"
|
||||||
|
ORGA_COLOR="#bcafff"
|
||||||
|
LIB_COLOR="#49afff"
|
||||||
|
|
||||||
|
# Built variables
|
||||||
output="$1"
|
output="$1"
|
||||||
SRC_DIR="${RERO_DIR}/data/"
|
SRC_DIR="${RERO_DIR}/data/"
|
||||||
|
|
||||||
|
# TESTS
|
||||||
|
if [[ -z "${output}" ]]; then
|
||||||
|
echo "No output file given"
|
||||||
|
exit 1
|
||||||
|
elif [[ -f "${output}" ]]; then
|
||||||
|
echo "File already exists!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# start of file
|
# start of file
|
||||||
echo "digraph {" > "$output"
|
echo "digraph {" > "$output"
|
||||||
echo "rankdir = RL;" >> "$output"
|
echo "rankdir = RL;" >> "$output"
|
||||||
@ -25,7 +38,7 @@ do
|
|||||||
code=$(echo $orga|jq -r .code)
|
code=$(echo $orga|jq -r .code)
|
||||||
name=$(echo $orga|jq -r .name)
|
name=$(echo $orga|jq -r .name)
|
||||||
# write result in output
|
# write result in output
|
||||||
echo "Orga${pid} [shape=box color=\"transparent\" style=filled fillcolor=\"#bcafff\" label=<${name}<br/>(code: ${code})>]" >> "$output"
|
echo "Orga${pid} [shape=box color=\"transparent\" style=filled fillcolor=\"${ORGA_COLOR}\" label=<${name}<br/>(code: ${code})>]" >> "$output"
|
||||||
done
|
done
|
||||||
|
|
||||||
# LIBRARIES
|
# LIBRARIES
|
||||||
@ -43,7 +56,7 @@ do
|
|||||||
orga_pid=$(echo $orga|rev|cut -d "/" -f 1|rev)
|
orga_pid=$(echo $orga|rev|cut -d "/" -f 1|rev)
|
||||||
# write result in output
|
# write result in output
|
||||||
l_id="Lib${pid}"
|
l_id="Lib${pid}"
|
||||||
echo "${l_id} [shape=house color=transparent style=filled fillcolor=\"#49afff\" label=<${name}<br/>(code: ${code})>]" >> "$output"
|
echo "${l_id} [shape=house color=transparent style=filled fillcolor=\"${LIB_COLOR}\" label=<${name}<br/>(code: ${code})>]" >> "$output"
|
||||||
echo "${l_id} -> Orga${orga_pid}" >> "$output"
|
echo "${l_id} -> Orga${orga_pid}" >> "$output"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -53,17 +66,49 @@ cat "${user_file}"|jq -c '.[] | {
|
|||||||
email,
|
email,
|
||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
library: .library."$ref"} | select(.library |length >= 1)'|while read user
|
barcode,
|
||||||
|
roles,
|
||||||
|
library: .library."$ref"}'|while read user
|
||||||
do
|
do
|
||||||
email=$(echo $user|jq -r .email)
|
email=$(echo $user|jq -r .email)
|
||||||
first_name=$(echo $user|jq -r .first_name)
|
first_name=$(echo $user|jq -r .first_name)
|
||||||
last_name=$(echo $user|jq -r .last_name)
|
last_name=$(echo $user|jq -r .last_name)
|
||||||
|
barcode=$(echo $user|jq -r .barcode)
|
||||||
|
roles=$(echo $user|jq -r .roles[])
|
||||||
library=$(echo $user|jq -r .library)
|
library=$(echo $user|jq -r .library)
|
||||||
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
|
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
|
||||||
|
|
||||||
|
if [[ "${roles}" != "null" ]]; then
|
||||||
|
displayed_roles=""
|
||||||
|
for role in ${roles}; do
|
||||||
|
color="black"
|
||||||
|
if [[ "${role}" == "system_librarian" ]]; then
|
||||||
|
color="${ORGA_COLOR}"
|
||||||
|
elif [[ "${role}" == "librarian" ]]; then
|
||||||
|
color="${LIB_COLOR}"
|
||||||
|
fi
|
||||||
|
displayed_roles="${displayed_roles}<font color='${color}'>${role}</font> "
|
||||||
|
done
|
||||||
|
fi
|
||||||
# write result in output
|
# write result in output
|
||||||
u_id="User_${email}"
|
u_id="User_${email}"
|
||||||
echo "\"${u_id}\" [label=<${first_name} ${last_name}<br/>${email}>]" >> "$output"
|
|
||||||
|
# Don't display barcode if no one
|
||||||
|
info=""
|
||||||
|
if [[ "${barcode}" != "null" ]]; then
|
||||||
|
info="${info}<br/>${barcode}"
|
||||||
|
fi
|
||||||
|
# Same for roles
|
||||||
|
if [[ -n "${displayed_roles}" ]]; then
|
||||||
|
info="${info}<br/>${displayed_roles}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "\"${u_id}\" [label=<${first_name} ${last_name}<br/>${email}${info}>]" >> "$output"
|
||||||
|
|
||||||
|
# Display a link if library_pid is not null
|
||||||
|
if [[ "${library_pid}" != "null" ]]; then
|
||||||
echo "\"${u_id}\" -> Lib${library_pid}" >> "$output"
|
echo "\"${u_id}\" -> Lib${library_pid}" >> "$output"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# end of file
|
# end of file
|
||||||
|
Reference in New Issue
Block a user