-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlf_voting_right_stats
executable file
·31 lines (26 loc) · 1.35 KB
/
lf_voting_right_stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
php-cgi /opt/liquid_feedback_core/showaccounts.php > /tmp/showaccounts.tmp
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
# n=`echo "SELECT COUNT(*) FROM privilege AS a JOIN member AS b ON a.member_id = b.id WHERE a.unit_id = $i AND a.voting_right = true AND b.locked = false" | psql liquid_feedback | head -n 3 | tail -n 1 | grep -o -E "[0-9]+"`
a=`echo "SELECT COUNT(*) FROM privilege AS a JOIN member AS b ON a.member_id = b.id WHERE a.unit_id = $i AND a.voting_right = true AND b.locked = false AND b.active = true" | psql liquid_feedback | head -n 3 | tail -n 1 | grep -o -E "[0-9]+"`
if [ $i -eq 1 ]; then
n=`grep unit= /tmp/showaccounts.tmp | wc -l`
else
n=`grep unit=$i /tmp/showaccounts.tmp | wc -l`
fi
if ( [ $i -eq "1" ] && [ "$n" -eq "0" ] ); then
echo "error3! $n"
exit 0
fi
qa=`echo "print(math.ceil($n^0.6))" | lua`
# qb=`echo "print(math.ceil($n^0.65))" | lua`
# qc=`echo "print(math.ceil($n^0.7))" | lua`
date=`date "+%a, %-d. %-m. %Y, %T CEST"`
part="<b>$n</b> stimmberechtigt, <b>$a</b> aktiv (Stimmabgabe-Quorum, aufgerundet: x^0.6=<b>$qa</b> Stimmen)<br />"
if [ $(head -n 1 /opt/liquid_feedback_statistics/$i.html | grep "$part" | wc -l) -eq 0 ]; then
text="$date: $part"
echo $text
sed -i "1i $text" /opt/liquid_feedback_statistics/$i.html
fi
done
rm /tmp/showaccounts.tmp