Orgas: cosmetics changes on result
This commit is contained in:
parent
7f0b1cca4f
commit
3406e4d596
@ -2,10 +2,18 @@
|
|||||||
|
|
||||||
*datagraph_generator* generates a diagram with **graphviz** with the link between organisations, libraries and users in *rero-ils* project.
|
*datagraph_generator* generates a diagram with **graphviz** with the link between organisations, libraries and users in *rero-ils* project.
|
||||||
|
|
||||||
|
# Requirements
|
||||||
|
|
||||||
|
* graphviz
|
||||||
|
* [jq](https://stedolan.github.io/jq/)
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
|
* Open **gen.sh** file
|
||||||
|
* change **RERO\_DIR** variable to point your **rero-ils directory**
|
||||||
|
|
||||||
```
|
```
|
||||||
make clean && make
|
make clean && make
|
||||||
```
|
```
|
||||||
|
|
||||||
Result: **datagraph.svg** file (can be open with Gimp for example).
|
Result: **organisations.svg** file (can be open with Gimp for example).
|
||||||
|
23
orgas/gen.sh
23
orgas/gen.sh
@ -1,15 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Generate a dot file to create graph of RERO-ils data (orga, lib and users)
|
||||||
|
#
|
||||||
|
|
||||||
# Generate a dot file to create digraph of RERO-ils data
|
RERO_DIR="${HOME}/projets/rero/rero-ils"
|
||||||
|
|
||||||
output="$1"
|
output="$1"
|
||||||
source="/home/od/projets/rero/rero-ils/data/"
|
SRC_DIR="${RERO_DIR}/data/"
|
||||||
|
|
||||||
# start of file
|
# start of file
|
||||||
echo "digraph {" > "$output"
|
echo "digraph {" > "$output"
|
||||||
|
echo "rankdir = RL;" >> "$output"
|
||||||
|
echo "label = \"Link between organisations, libraries and users.\";" >> "$output"
|
||||||
|
|
||||||
# ORGANISATIONS
|
# ORGANISATIONS
|
||||||
orga_file="${source}organisations.json"
|
orga_file="${SRC_DIR}organisations.json"
|
||||||
cat "${orga_file}"|jq -c '.[] | {
|
cat "${orga_file}"|jq -c '.[] | {
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
@ -20,28 +25,30 @@ 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} [label=\"${name}\"]" >> "$output"
|
echo "Orga${pid} [shape=box color=\"transparent\" style=filled fillcolor=\"#bcafff\" label=<${name}<br/>(code: ${code})>]" >> "$output"
|
||||||
done
|
done
|
||||||
|
|
||||||
# LIBRARIES
|
# LIBRARIES
|
||||||
lib_file="${source}libraries.json"
|
lib_file="${SRC_DIR}libraries.json"
|
||||||
cat "${lib_file}"|jq -c '.[] | {
|
cat "${lib_file}"|jq -c '.[] | {
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
|
code,
|
||||||
organisation: .organisation."$ref"}'|while read lib
|
organisation: .organisation."$ref"}'|while read lib
|
||||||
do
|
do
|
||||||
pid=$(echo $lib|jq -r .pid)
|
pid=$(echo $lib|jq -r .pid)
|
||||||
name=$(echo $lib|jq -r .name)
|
name=$(echo $lib|jq -r .name)
|
||||||
|
code=$(echo $lib|jq -r .code)
|
||||||
orga=$(echo $lib|jq -r .organisation)
|
orga=$(echo $lib|jq -r .organisation)
|
||||||
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} [label=\"${name}\"]" >> "$output"
|
echo "${l_id} [shape=house color=transparent style=filled fillcolor=\"#49afff\" label=<${name}<br/>(code: ${code})>]" >> "$output"
|
||||||
echo "${l_id} -> Orga${orga_pid}" >> "$output"
|
echo "${l_id} -> Orga${orga_pid}" >> "$output"
|
||||||
done
|
done
|
||||||
|
|
||||||
# USERS
|
# USERS
|
||||||
user_file="${source}users.json"
|
user_file="${SRC_DIR}users.json"
|
||||||
cat "${user_file}"|jq -c '.[] | {
|
cat "${user_file}"|jq -c '.[] | {
|
||||||
email,
|
email,
|
||||||
first_name,
|
first_name,
|
||||||
@ -55,7 +62,7 @@ do
|
|||||||
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
|
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
|
||||||
# write result in output
|
# write result in output
|
||||||
u_id="User_${email}"
|
u_id="User_${email}"
|
||||||
echo "\"${u_id}\" [label=\"${first_name} ${last_name}\"]" >> "$output"
|
echo "\"${u_id}\" [label=<${first_name} ${last_name}<br/>${email}>]" >> "$output"
|
||||||
echo "\"${u_id}\" -> Lib${library_pid}" >> "$output"
|
echo "\"${u_id}\" -> Lib${library_pid}" >> "$output"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user