onStat publishes a "complete" event when the number of active clients
authorMike Taylor <mike@indexdata.com>
Tue, 8 Apr 2014 16:08:57 +0000 (17:08 +0100)
committerMike Taylor <mike@indexdata.com>
Tue, 8 Apr 2014 16:08:57 +0000 (17:08 +0100)
falls to zero. This enables us to make a "search is complete" widget,
which fixes bugs MKWS-48 and MKWS-49.

src/mkws-team.js

index ee18f1b..4447457 100644 (file)
@@ -115,8 +115,9 @@ function team($, teamName) {
     }
 
     function onStat(data) {
-       log("stat");
        queue("stat").publish(data);
+       if (parseInt(data.activeclients[0], 10) === 0)
+           queue("complete").publish(parseInt(data.hits[0], 10));
     }
 
     function onTerm(data) {