3 DIR=$(readlink -f $(dirname $0))
7 PGHOST=prod-pg96-db2-sitka
8 PSQL="psql -A -t -U $PGUSER -h $PGHOST"
10 MUCN_QUERY="select distinct record FROM asset.call_number where owning_lib in (select distinct id from actor.org_unit_descendants(1400)) and not deleted and label != '##URI##';"
11 MARC_PARAMS="--config /srv/openils/conf/opensrf_core.xml --items --location MUCN --collapse_to_depth 2 --timeout 300 --force901 --encoding UTF-8 --onlyholdings --quiet"
12 MARC_EXPORT_BIN="${DIR}/marc_export_custom"
13 # this lets us inject perl opts
14 MARC_EXPORT="perl ${PERLOPT} -- ${MARC_EXPORT_BIN} ${MARC_PARAMS}"
16 [ -z "${T}" ] && T=$(date -u +%Y%m%dT%H%M%SZ)
17 [ -z "${OUTDIR}" ] && OUTDIR=$(mktemp --tmpdir -d outlook_export.XXXXXXX)
20 local f="$1" sql="$2" split_count="$3"
21 if [ ! -f ${OUTDIR}/${f}-${T}.id ]; then
23 $PSQL -c "$sql" $DATABASE | sort | uniq >${OUTDIR}/${f}-${T}.id
25 if [ ! -f ${OUTDIR}/${f}.id.targets ]; then
27 split_suffix ${OUTDIR}/${f}-${T}.id ${OUTDIR}/${f}-${T}-split. .id $split_count
29 find ${OUTDIR} -name "${f}-${T}-split.[0-9]*[0-9].id" \
30 | sed 's,.id$,.marc,g' \
31 >${OUTDIR}/${f}.id.targets
34 make ${MAKEOPTS} -f Makefile-marc_export \
35 MARC_EXPORT_BIN="${MARC_EXPORT_BIN}" \
36 MARC_PARAMS="$MARC_PARAMS --exclusion_ini ${f}.ini" \
37 $(<${OUTDIR}/${f}.id.targets)
39 find ${OUTDIR} -name "${f}-${T}-split*.marc" \
41 >${OUTDIR}/${f}-${T}.marc
45 local input="$1" output_prefix="$2" output_suffix="$3" split_count="$4"
46 split -a 7 -d -C ${split_count} ${input} ${output_prefix}
47 find $(dirname ${output_prefix}) -name "$(basename ${output_prefix})*" -exec mv -f \{\} \{\}${output_suffix} \;
50 # media for BC ELN post-secondary libraries
51 export SPLIT_COUNT=10000
52 F=mucn_ebsco SQL="$MUCN_QUERY"
53 process_batch "$F" "${SQL}" $SPLIT_COUNT