webbuild: switch social_log to sqlite3 db; display status also when there are no processes to display
This commit is contained in:
parent
ced497545e
commit
c3cbf7c0e8
@ -214,29 +214,31 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then
|
||||
if [ "$WEBBUILD_URL" -a "${WEBBUILD_URL/\/localhost\//}" = "$WEBBUILD_URL" ]; then
|
||||
curl -s "$WEBBUILD_URL?REQUEST=refreshsocial&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&FROMID=$FROMID"
|
||||
else
|
||||
[ -e "$WEBBUILD_STATEDIR/social_log" ] || exit
|
||||
[ -e "$WEBBUILD_STATEDIR/webbuild.db" ] || exit
|
||||
# social box
|
||||
echo -n "<socialbox>"
|
||||
count=0
|
||||
SID=0
|
||||
if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then
|
||||
if [ "$USER" ]; then
|
||||
line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " SUSER=$USER " 2>/dev/null | tail -n 25 | head -n 1`
|
||||
# Find id of last row - 25
|
||||
if [ "$USER"]; then
|
||||
LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE user!='$USER' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;"
|
||||
else
|
||||
line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " STARGET=developers " 2>/dev/null | tail -n 25 | head -n 1`
|
||||
LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE target!='$DEVELOPERS' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;"
|
||||
fi
|
||||
eval $line
|
||||
FROMID=$SID
|
||||
FROMID=`sqlite3 $WEBBUILD_STATEDIR/webbuild.db "$LASTID_QUERY"`
|
||||
fi
|
||||
tail -n 100 $WEBBUILD_STATEDIR/social_log | while read line; do
|
||||
STYPE=
|
||||
SPRIVACY=
|
||||
SUSER=
|
||||
STARGET=
|
||||
SID=
|
||||
eval $line
|
||||
[ "$SID" ] || continue
|
||||
[ $SID -ge $FROMID ] || continue
|
||||
sqlite3 $WEBBUILD_STATEDIR/webbuild.db "select *,strftime('%s',time) from social_log where id>$FROMID" | while read line; do
|
||||
SAVEIFS=$IFS
|
||||
IFS="|"
|
||||
set -- $line
|
||||
SID="$1"
|
||||
SPRIVACY="$2"
|
||||
SUSER="$3"
|
||||
STYPE="$4"
|
||||
STARGET="$5"
|
||||
SEMAIL="$6"
|
||||
STEXT="$7"
|
||||
STIME="$9"
|
||||
[ "$STARGET" = "developers" -a ! "$USER" ] && continue
|
||||
[ "$SUSER" = "$USER" -a "$STARGET" == "developers" ] && continue
|
||||
if [ "$SPRIVACY" -a ! "$USER" ]; then
|
||||
@ -253,7 +255,6 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then
|
||||
fi
|
||||
echo -n "<div style=\"position:relative;margin-left:24px;height:auto;padding:0;\"><b>$SUSER</b> $STEXT <i><span name=socialtime time=$STIME></span></i></div>"
|
||||
echo -n "</div><div style=\"clear:both;\"><hr></div>]]></add>"
|
||||
count=$(($count + 1))
|
||||
done
|
||||
echo -n "</socialbox>"
|
||||
fi
|
||||
@ -381,18 +382,6 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
|
||||
echo -n "</div>"
|
||||
fi
|
||||
|
||||
numprocess=0
|
||||
tac $WEBBUILD_STATEDIR/processes | \
|
||||
while read line; do
|
||||
set -- $line
|
||||
RETCODE=$6
|
||||
PROCESSLOG=$5
|
||||
# if [ -e /proc/$1 -o $5 -lt 256 ]; then
|
||||
numprocess=$(($numprocess + 1))
|
||||
cmdline=`echo "$line" | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"`
|
||||
cmdline=`echo "$cmdline" | sed "s| --colors web||"`
|
||||
PACKAGE_ENCODED=`cgi_encodevar $4`
|
||||
[ $numprocess -eq 1 ] && {
|
||||
# echo -n "<div align=left class=processes>"
|
||||
u="$(uptime)"
|
||||
f="$(df / -k -h --output=avail,pcent|tail -n1)"
|
||||
@ -406,7 +395,17 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
|
||||
echo "All jobs: [<a href=# onclick=ajax_getvalues(\"REQUEST=refreshjobs&JOBSSHOWALL=false\");>Only show my jobs</a>]"
|
||||
fi
|
||||
echo -n "<br>"
|
||||
}
|
||||
|
||||
numprocess=0
|
||||
tac $WEBBUILD_STATEDIR/processes | \
|
||||
while read line; do
|
||||
set -- $line
|
||||
RETCODE=$6
|
||||
PROCESSLOG=$5
|
||||
numprocess=$(($numprocess + 1))
|
||||
cmdline=`echo "$line" | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"`
|
||||
cmdline=`echo "$cmdline" | sed "s| --colors web||"`
|
||||
PACKAGE_ENCODED=`cgi_encodevar $4`
|
||||
[ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue
|
||||
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
|
||||
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" width=10 height=10 src=\"/images/inprogress.gif\" alt=\"running...\" title=\"running...\">"
|
||||
|
@ -27,15 +27,21 @@ function set_user_state_var() {
|
||||
|
||||
function social_log() {
|
||||
local line=$1
|
||||
local SPRIVACY=0
|
||||
|
||||
[ "$line" ] || return
|
||||
|
||||
if [ ! "$STATE_FAKEUSER" ]; then
|
||||
STATE_SOCIALLOG_ID=0
|
||||
. $WEBBUILD_STATEDIR/users/webbuild.state
|
||||
STATE_SOCIALLOG_ID=$(($STATE_SOCIALLOG_ID + 1))
|
||||
set_user_state_var STATE_SOCIALLOG_ID $STATE_SOCIALLOG_ID webbuild
|
||||
echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $WEBBUILD_STATEDIR/social_log
|
||||
|
||||
[ -e $WEBBUILD_STATEDIR/webbuild.db ] || \
|
||||
sqlite3 $WEBBUILD_STATEDIR/webbuild.db \
|
||||
"CREATE TABLE social_log(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, privacy BOOLEAN, user CHAR(40), type CHAR(40), target CHAR(40), email CHAR(80), text TEXT, time datetime default current_timestamp);"
|
||||
|
||||
eval "$line"
|
||||
[ "$STATE_PRIVACYMODE" ] && $SPRIVACY=1
|
||||
sqlite3 $WEBBUILD_STATEDIR/webbuild.db \
|
||||
"INSERT into social_log (privacy, user, type, target, email, text) \
|
||||
values ($SPRIVACY,'$SUSER','$STYPE','$STARGET','$SEMAIL','$STEXT');"
|
||||
|
||||
# Note: checking that URL does not point here again to avoid recursive requests
|
||||
if [ "$WEBBUILD_URL" -a "${WEBBUILD_URL/\/localhost\//}" = "$WEBBUILD_URL" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user