#!/bin/bash

ROOT=/home/shquier/easyconf.net/easychair

OUT=$ROOT/bak/workflow_inventory.txt

exec > "$OUT"

echo "===================================================="
echo " EASYCONF ENTERPRISE WORKFLOW INVENTORY"
echo "===================================================="
echo

echo "===== UPDATE submissions ====="
grep -Rni \
"UPDATE[[:space:]]\+submissions" \
$ROOT/app \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== INSERT review_assignments ====="
grep -Rni \
"INSERT INTO review_assignments" \
$ROOT/app \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== UPDATE review_assignments ====="
grep -Rni \
"UPDATE[[:space:]]\+review_assignments" \
$ROOT/app \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== SubmissionWorkflowService ====="
grep -Rni \
"SubmissionWorkflowService::" \
$ROOT/app \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== WorkflowDecisionService ====="
grep -Rni \
"WorkflowDecisionService::" \
$ROOT/app \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===== workflow_stage ====="
grep -Rni \
"workflow_stage" \
$ROOT/app \
--include="*.php" \
| grep -Ev "\.bak|\.before|\.old|\.orig|\.save|\.broken|backup|backups|\(Copy\)"

echo
echo "===================================================="
echo " END"
echo "===================================================="

