Browse Source

sql - include hold info on the end of each luck report line

master
kanoi 9 years ago
parent
commit
6eb398485f
  1. 38
      sql/luck.sh

38
sql/luck.sh

@ -6,6 +6,7 @@ tmp1="$tmp.1.sql"
tmp2="$tmp.2.sql" tmp2="$tmp.2.sql"
tmp3="$tmp.3.sql" tmp3="$tmp.3.sql"
tmp4="$tmp.4.sql" tmp4="$tmp.4.sql"
tmp5="$tmp.5.sql"
msdd="1,000,000,000" msdd="1,000,000,000"
msd="`echo "$msdd" | tr -d ,`" msd="`echo "$msdd" | tr -d ,`"
# #
@ -90,12 +91,17 @@ toG()
# #
dedup() dedup()
{ {
cut -d '|' -f 1-5,7-10,12 cut -d '|' -f 1-5,7-10,12-
} }
# #
dedupw() dedupw()
{ {
cut -d '|' -f 1-4,6-9,11 cut -d '|' -f 1-4,6-9,11-
}
#
debar()
{
sed -e "s/[ |]*$//" -e "s/|[ |]*|/|/g"
} }
# #
p1="$((0x1d))" p1="$((0x1d))"
@ -152,6 +158,7 @@ proc()
break break
fi fi
uorw="`echo "$line" | cut -d'|' -f1 | tr -d ' '`" uorw="`echo "$line" | cut -d'|' -f1 | tr -d ' '`"
uws="`echo "$uorw" | sed -e "s/\(^[^_\.]*\)[_\.].*$/\1/"`"
diffs="`getdiff` BDR" diffs="`getdiff` BDR"
if [ "${diffs:0:1}" = "." ] ; then if [ "${diffs:0:1}" = "." ] ; then
diffs=" 0$diffs" diffs=" 0$diffs"
@ -162,17 +169,18 @@ proc()
fi fi
stats="`grep "^$uorw *|" "$tmp2"`" stats="`grep "^$uorw *|" "$tmp2"`"
bstats="`grep "^$uorw *|" "$tmp3"`" bstats="`grep "^$uorw *|" "$tmp3"`"
hstats="`grep "^$uws *|" "$tmp5" | cut -d'|' -f2 | sed -e "s/6666-06-06 //"`"
if [ "$stats" ] ; then if [ "$stats" ] ; then
s=" | " s=" | $stats"
else else
s="" s=" | | | | | "
fi fi
if [ "$bstats" ] ; then if [ "$bstats" ] ; then
b=" | " b=" | $bstats"
else else
b="" b=" | |"
fi fi
echo "$line | $diffs$s$stats$b$bstats" echo "$line | $diffs$s$b |$hstats"
done done
} }
# #
@ -312,7 +320,19 @@ sql="$sql0 from markersummary ms join workmarkers wm on ms.markerid=wm.markerid
# #
dosql | diff1 > "$tmp4" dosql | diff1 > "$tmp4"
# #
if [ -z "$work" ] ; then
sql0="select userid"
sqlz="group by userid"
else
sql0="select username"
sqlz="group by username"
fi
#
sql="$sql0,substring(max(expirydate)::varchar from 1 for 10)||' Hold' from useratts where attname='HoldPayouts' $sqlz;"
#
dosql > "$tmp5"
#
# join (append) to each tmp1 row, the matching row/data in tmp4, tmp2 and tmp3 # join (append) to each tmp1 row, the matching row/data in tmp4, tmp2 and tmp3
cat "$tmp1" | proc | toG | dedup$work cat "$tmp1" | proc | toG | dedup$work | debar
# #
shred -uz "$tmp0" "$tmp1" "$tmp2" "$tmp3" "$tmp4" &> /dev/null shred -uz "$tmp0" "$tmp1" "$tmp2" "$tmp3" "$tmp4" "$tmp5" &> /dev/null

Loading…
Cancel
Save