Skip to content

Commit

Permalink
Update utilities/contacts-from-sf.sh due to changes in the salesforce…
Browse files Browse the repository at this point in the history
… report

See #236
  • Loading branch information
Jon Agland committed Nov 11, 2020
1 parent 91c978a commit b1f468a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions utilities/contacts-from-sf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
# Author: Jon Agland <jon.agland@jisc.ac.uk>
#

SFREPORTNAME="UKfed-contacts-export"
UKFDATA=../../ukf-data
CSVDEST=../../ukf-data/contacts/sf-contacts.csv
CONTACTDEST=../../ukf-data/contacts/sf-contacts.txt
MGMTDEST=../../ukf-data/contacts/sf-contacts-mc.txt
TMPFILE=$(mktemp)

if [ -z "$1" ]; then
echo "ERROR: No file name supplied"
Expand All @@ -35,13 +36,17 @@ if [ ! -f "$1" ]; then
exit 1
fi

if ! grep -q \"$SFREPORTNAME\" $1; then
echo "ERROR: this doesn't appear to be the output of $SFREPORTNAME"
exit 2
fi

cat $1 | awk -F\, '{ print $1 }' | grep @ | sed -e 's/\"//g' | sort -u > $CONTACTDEST
grep "\,\"UK Federation Management Contact\"" $1 | awk -F\, '{ print $1 }' | grep @ | sed -e 's/\"//g' | sort -u > $MGMTDEST

cp $1 $CSVDEST
SOURCEDATE=$(date --date="@$(stat $1 --printf=%Y | awk -F\. '{ print $1 }')" +"%d/%m/%Y %H:%M")


GITUSER=$(cd $UKFDATA && git config user.name)

cp $1 $TMPFILE
echo "\"Generated By: $GITUSER $SOURCEDATE\"" >> $TMPFILE

cp $TMPFILE $CSVDEST
rm $TMPFILE

0 comments on commit b1f468a

Please sign in to comment.