3 DIR=$(readlink -f $(dirname $0))
7 PGHOST=dbprod-96-main-ndb2
8 PSQL="psql -A -t -U $PGUSER -h $PGHOST"
10 #FULL_QUERY="select distinct id from biblio.record_entry where not deleted"
11 #FULL_QUERY="select distinct acn.record FROM asset.call_number acn join biblio.record_entry bre on (acn.record = bre.id) where not bre.deleted and bre.active and not acn.deleted"
12 FULL_QUERY="select distinct acn.record FROM asset.call_number acn join biblio.record_entry bre on (acn.record = bre.id) where not bre.deleted and bre.active and not acn.deleted and acn.label != '##URI##' AND acn.owning_lib IN (SELECT id FROM actor.org_unit_descendants(21) UNION SELECT id FROM actor.org_unit_descendants(600) )"
13 NONEXPORTED_QUERY="select distinct acn.record FROM asset.call_number acn join biblio.record_entry bre on (acn.record = bre.id) where bre.deleted or not bre.active or acn.deleted"
14 MARC_PARAMS="--config /srv/openils/conf/opensrf_core.xml --items --location SITKA --collapse_to_depth 3 --timeout 300 --force901 --encoding UTF-8 --onlyholdings --quiet --field-852-4b-type circ"
15 MARC_EXPORT_BIN="${DIR}/marc_export_custom"
16 # this lets us inject perl opts
17 MARC_EXPORT="perl ${PERLOPT} -- ${MARC_EXPORT_BIN} ${MARC_PARAMS}"
19 [ -z "${T}" ] && T=$(date -u +%Y%m%dT%H%M%SZ)
20 [ -z "${OUTDIR}" ] && OUTDIR=$(mktemp --tmpdir -d outlook_export.XXXXXXX)
23 local f="$1" sql="$2" split_count="$3"
24 if [ ! -f ${OUTDIR}/${f}-${T}.id ]; then
26 $PSQL -c "$sql" $DATABASE | sort | uniq >${OUTDIR}/${f}-${T}.id
28 if [ ! -f ${OUTDIR}/${f}.id.targets ]; then
30 split_suffix ${OUTDIR}/${f}-${T}.id ${OUTDIR}/${f}-${T}-split. .id $split_count
32 find ${OUTDIR} -name "${f}-${T}-split.[0-9]*[0-9].id" \
33 | sed 's,.id$,.marc,g' \
34 >${OUTDIR}/${f}.id.targets
37 make ${MAKEOPTS} -f Makefile-marc_export \
38 MARC_EXPORT_BIN="${MARC_EXPORT_BIN}" \
39 MARC_PARAMS="$MARC_PARAMS --exclusion_ini ${f}.ini" \
40 $(<${OUTDIR}/${f}.id.targets)
43 find ${OUTDIR} -name "${f}-${T}-split*.marc" \
45 >${OUTDIR}/${f}-${T}.marc
50 local input="$1" output_prefix="$2" output_suffix="$3" split_count="$4"
51 split -a 7 -d -C ${split_count} ${input} ${output_prefix}
52 find $(dirname ${output_prefix}) -name "$(basename ${output_prefix})*" -exec mv -f \{\} \{\}${output_suffix} \;
55 export SPLIT_COUNT=100000
56 # full dump for outlook public libraries
57 F=sitka_full_outlook SQL="$FULL_QUERY"
58 process_batch "$F" "${SQL}" $SPLIT_COUNT