|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# assume we're in bin/, sibling to ietf/ |
| 4 | + |
| 5 | +cd ${0%/*}/../ietf || { echo "CD to ietf directory failed, bailing out"; exit; } |
| 6 | + |
| 7 | +trap 'echo "$program($LINENO): Command failed with error code $? ($0 $*)"; exit 1' ERR |
| 8 | + |
| 9 | +if [ "$*" ]; then apps="$@"; graph="${1%.*}"; else apps=$(ls */models.py | sed 's!/models.py!!'); graph="models"; fi |
| 10 | + |
| 11 | +newapps="doc group meeting message person name" |
| 12 | +legacyapps="announcements idindex idrfc idtracker iesg ietfauth ietfworkflows ipr liaisons mailinglists proceedings redirects submit wgchairs wgcharter wginfo" |
| 13 | + |
| 14 | +proxy="$(grep ^class */proxy.py | tr '()' ' ' | awk '{printf $2 ","}')" |
| 15 | +names="$(grep ^class name/models.py | tr '()' ' ' | awk '{printf $2 ","}')" |
| 16 | +legacy="$(for app in $legacyapps; do grep ^class $app/models.py | tr '()' ' '; done | grep -v ' Meeting\\(' | awk '{printf $2 ","}')" |
| 17 | +events="$(egrep '^class .+DocEvent' doc/models.py | tr '()' ' ' | awk '{printf $2 ","}')" |
| 18 | + |
| 19 | +echo -e "proxy: $proxy\n" |
| 20 | +echo -e "names: $names\n" |
| 21 | +echo -e "legacy:$legacy\n" |
| 22 | +echo -e "events:$events\n" |
| 23 | + |
| 24 | +exclude="--exclude=$proxy,$names,$legacy" |
| 25 | + |
| 26 | +export PYTHONPATH="$PWD/.." |
| 27 | + |
| 28 | +echo "Validating..." |
| 29 | +./manage.py validate |
| 30 | + |
| 31 | +echo "Dump tables" |
| 32 | +./manage.py sql $apps > tables.sql |
| 33 | +export PYTHONPATH=`dirname $PWD` |
| 34 | +module=${PWD##*/} |
| 35 | +export DJANGO_SETTINGS_MODULE=$module.settings |
| 36 | +export graph |
| 37 | +export title |
| 38 | +echo "Generate model graph" |
| 39 | +graph="models-with-names-and-events" |
| 40 | +title="New IETF Database schema" |
| 41 | +modelviz.py --exclude="$proxy,$legacy" --title "$title" $apps > $graph.dot && dot -Tpng $graph.dot > $graph.png |
| 42 | + |
| 43 | +echo "Generate new model without names" |
| 44 | +graph="models-with-names" |
| 45 | +title="New IETF Database schema, without name tables" |
| 46 | +modelviz.py --exclude="$proxy,$legacy,$names" --title "$title" $apps > $graph.dot && dot -Tpng $graph.dot > $graph.png |
| 47 | + |
| 48 | +echo "Generate new model without names and subevents" |
| 49 | +graph="models" |
| 50 | +title="New IETF Database schema, without name tables and subevents" |
| 51 | +modelviz.py --exclude="$proxy,$legacy,$names,$events" --title "$title" $apps > $graph.dot && dot -Tpng $graph.dot > $graph.png |
0 commit comments