ODT
/
rero-ils-graphs
Archived
1
0
Fork 0

Orgas: export jq filtering outside gen.sh code (simplification)

master
Olivier DOSSMANN 2020-02-07 13:51:32 +01:00
parent 86224fef7f
commit 9f9feb2a93
7 changed files with 39 additions and 31 deletions

View File

@ -1,6 +1,5 @@
# TODO list
* item -> item_types -> patron_types -> circulation policies + organisations
* patron_types on organisations.svg
* do it in Python
* use http://localhost:9200/patrons/_search?size=50 and similar to create all graphs? => problem: you need to launch docker-compose and load data (setup), which takes time

View File

@ -40,6 +40,12 @@ save() {
rendered_template="$(render $1)"
send "${rendered_template}"
}
# parse_json: read JSON file (filename given in $1) and applying filter (same name as $1)
parse_json() {
filepath="${SRC_DIR}/$1.json"
filter="filters/$1"
cat "$filepath" | jq -cf "$filter"
}
# Output file initialization
echo "" > "$outputfile" # flush output file

View File

@ -0,0 +1,6 @@
.[] | {
name,
pid,
code,
organisation: .organisation."$ref"
}

View File

@ -0,0 +1,5 @@
.[] | {
name,
pid,
code
}

View File

@ -0,0 +1,5 @@
.[] | {
pid,
name,
organisation: .organisation."$ref"
}

View File

@ -0,0 +1,9 @@
.[] | {
email,
first_name,
last_name,
barcode,
roles,
library: .library."$ref",
pt: .patron_type."$ref"
}

View File

@ -33,13 +33,9 @@ title="Link between organisations, libraries and users."
save "templates/header.tmpl"
# ORGANISATIONS
orga_file="${SRC_DIR}organisations.json"
shape="box"
color="${ORGA_COLOR}"
cat "${orga_file}"|jq -c '.[] | {
name,
pid,
code }'| while read orga
while read -r orga
do
# take important info
pid=$(echo $orga|jq -r .pid)
@ -49,17 +45,12 @@ do
identifier="Orga${pid}"
label="$(render ${tmpl_label})"
save "${tmpl_gizmo}"
done
done <<< $(parse_json "organisations")
# LIBRARIES
lib_file="${SRC_DIR}libraries.json"
shape="house"
color="${LIB_COLOR}"
cat "${lib_file}"|jq -c '.[] | {
name,
pid,
code,
organisation: .organisation."$ref"}'|while read lib
while read -r lib
do
pid=$(echo $lib|jq -r .pid)
name=$(echo $lib|jq -r .name)
@ -72,17 +63,13 @@ do
save "${tmpl_gizmo}"
relation="Orga${orga_pid}"
save "${tmpl_link}"
done
done <<< $(parse_json "libraries")
# PATRON_TYPES
pt_file="${SRC_DIR}patron_types.json"
shape="polygon"
color="${PT_COLOR}"
additionals="sides=7"
cat "${pt_file}" |jq -c '.[] | {
pid,
name,
organisation: .organisation."$ref"}'|while read pt
while read pt
do
pid=$(echo $pt|jq -r .pid)
name=$(echo $pt|jq -r .name)
@ -98,21 +85,13 @@ do
relation="Orga${orga_pid}"
save "${tmpl_link}"
fi
done
done <<< $(parse_json "patron_types")
# USERS
user_file="${SRC_DIR}users.json"
shape="ellipse"
additionals=''
color="${USER_COLOR}"
cat "${user_file}"|jq -c '.[] | {
email,
first_name,
last_name,
barcode,
roles,
library: .library."$ref",
pt: .patron_type."$ref"}'|while read user
while read user
do
email=$(echo $user|jq -r .email)
first_name=$(echo $user|jq -r .first_name)
@ -157,11 +136,10 @@ do
relation="Type${pt_id}"
save "${tmpl_link}"
fi
done
done <<< $(parse_json "users")
# Graph footer
save "templates/footer.tmpl"
# END of program
exit 0