#!/bin/sh
# Copyright (c) 2010-2013 Index Data, http://www.indexdata.com
#
# pazpar2-error-statistic-realtime - update failed queries statistics nearly in real time

# die on error
set -e
umask 002

# LANG=en_US.UTF-8 make egrep 10 times slower
export LANG=C

stat_dir=/var/lib/cf-repo/.statistic
file=$stat_dir/.reliability-today-full-query.csv

# use development installation if exists
if [ -d /home/indexdata/pazpar2-statistic/bin ]; then
   cd /home/indexdata/pazpar2-statistic/bin
else
   cd /usr/share/pazpar2-statistic/bin
fi

make -s today-full-query > $file.tmp && mv -f $file.tmp $file
