From: Sebastian Hammer
Date: Thu, 4 Jan 2007 02:53:37 +0000 (+0000)
Subject: Implemented 'activeclients' result element for cmd_stat. Put check in test1 client for
X-Git-Tag: before.append.child~51
X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=28589aa29d2c105b8862116b7466110f77bc7b35;p=pazpar2-moved-to-github.git
Implemented 'activeclients' result element for cmd_stat. Put check in test1 client for
show, stat, and termlist handlers, so browser now produces no unnecessary HTML traffic.
---
diff --git a/PROTOCOL b/PROTOCOL
index 272d9c6..5e3ad07 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -66,6 +66,7 @@ search.pz2?session=2044502273&command=stat
Output:
+ 3
7 -- Total hitcount
7 -- Total number of records fetched
1 -- Total number of associated clients
diff --git a/src/http_command.c b/src/http_command.c
index c5dcf0f..c4837a6 100644
--- a/src/http_command.c
+++ b/src/http_command.c
@@ -1,5 +1,5 @@
/*
- * $Id: http_command.c,v 1.4 2007-01-04 02:35:42 quinn Exp $
+ * $Id: http_command.c,v 1.5 2007-01-04 02:53:37 quinn Exp $
*/
#include
@@ -364,6 +364,7 @@ static void cmd_stat(struct http_channel *c)
struct http_response *rs = c->response;
struct http_session *s = locate_session(rq, rs);
struct statistics stat;
+ int clients = session_active_clients(s->psession);
if (!s)
return;
@@ -372,6 +373,7 @@ static void cmd_stat(struct http_channel *c)
wrbuf_rewind(c->wrbuf);
wrbuf_puts(c->wrbuf, "");
+ wrbuf_printf(c->wrbuf, "%d\n", clients);
wrbuf_printf(c->wrbuf, "%d\n", stat.num_hits);
wrbuf_printf(c->wrbuf, "%d\n", stat.num_records);
wrbuf_printf(c->wrbuf, "%d\n", stat.num_clients);
diff --git a/www/test1/search.js b/www/test1/search.js
index 60de378..d9c6af3 100644
--- a/www/test1/search.js
+++ b/www/test1/search.js
@@ -1,4 +1,4 @@
-/* $Id: search.js,v 1.3 2007-01-02 11:02:50 sondberg Exp $
+/* $Id: search.js,v 1.4 2007-01-04 02:53:37 quinn Exp $
* ---------------------------------------------------
* Javascript container
*/
@@ -130,6 +130,7 @@ function show_records()
var merged = Number(xml.getElementsByTagName('merged')[0].childNodes[0].nodeValue);
var start = Number(xml.getElementsByTagName('start')[0].childNodes[0].nodeValue);
var num = Number(xml.getElementsByTagName('num')[0].childNodes[0].nodeValue);
+ var clients = Number(xml.getElementsByTagName("activeclients")[0].childNodes[0].nodeValue);
body.innerHTML = 'Records : ';
body.innerHTML += (start + 1) + ' to ' + (start + num) +
' of ' + merged + ' (total hits: ' + total + ')';
@@ -157,10 +158,13 @@ function show_records()
body.innerHTML += '
';
}
shown++;
- if (shown < 5)
- searchtimer = setTimeout(check_search, 1000);
- else
- searchtimer = setTimeout(check_search, 2000);
+ if (clients > 0)
+ {
+ if (shown < 5)
+ searchtimer = setTimeout(check_search, 1000);
+ else
+ searchtimer = setTimeout(check_search, 2000);
+ }
}
if (!termtimer)
termtimer = setTimeout(check_termlist, 1000);
@@ -200,6 +204,8 @@ function show_termlist()
var xml = xtermlist.responseXML;
var body = document.getElementById("termlist");
var hits = xml.getElementsByTagName("term");
+ var clients =
+ Number(xml.getElementsByTagName("activeclients")[0].childNodes[0].nodeValue);
if (!hits[0])
{
termtimer = setTimeout(check_termlist, 1000);
@@ -217,7 +223,8 @@ function show_termlist()
'';
body.innerHTML += '
';
}
- termtimer = setTimeout(check_termlist, 2000);
+ if (clients > 0)
+ termtimer = setTimeout(check_termlist, 2000);
}
}
@@ -241,6 +248,8 @@ function show_stat()
var xml = xstat.responseXML;
var body = document.getElementById("stat");
var nodes = xml.childNodes[0].childNodes;
+ var clients =
+ Number(xml.getElementsByTagName("activeclients")[0].childNodes[0].nodeValue);
if (!nodes[0])
{
stattimer = setTimeout(check_stat, 500);
@@ -259,7 +268,8 @@ function show_stat()
body.innerHTML += ' ' + name + '=' + value;
}
body.innerHTML += ')';
- stattimer = setTimeout(check_stat, 2000);
+ if (clients > 0)
+ stattimer = setTimeout(check_stat, 2000);
}
}