diff --git a/code/common/html.q b/code/common/html.q index c927c8272..b446ccca0 100644 --- a/code/common/html.q +++ b/code/common/html.q @@ -35,7 +35,7 @@ sel:{[x;y] x} // Apply the modifier before sending the data pub:{[t;x]{[t;x;w]if[count x:sel[x]w 1;(neg first w) modifier[t]@(`upd;t;x)]}[t;x]each w t} -add:{$[(count w x)>i:w[x;;0]?.z.w;.[`.u.w;(x;i;1);union;y];w[x],:enlist(.z.w;y)];(x;$[99=type v:value x;sel[v]y;@[0#v;`sym;`g#]])} +add:{$[(count w x)>i:w[x;;0]?.z.w;.[`.u.w;(x;i;1);union;y];w[x],:enlist(.z.w;y)];(x;$[99=type v:value x;sel[v]y;98=type v;@[0#v;`sym;`g#];()])} sub:{if[x~`;:sub[;y]each t];if[not x in t;'x];del[x].z.w;add[x;y]} // add wssub method - have to subscribe to everything, don't return anything diff --git a/docs/visualisation.md b/docs/visualisation.md index 4934898b4..be3f2ce8d 100755 --- a/docs/visualisation.md +++ b/docs/visualisation.md @@ -106,6 +106,10 @@ kdb+ process and subscribe for updates. Subscriptions are done using .html.wssub[`tablename] +The subscription name does not have to be a table. It can be any name passed +to .html.init, for example the monitor's `lmchart`, which publishes the +output of a function. + Publications from the kdb+ side are done with .html.pub[`tablename;tabledata] diff --git a/tests/html/html.csv b/tests/html/html.csv new file mode 100644 index 000000000..db0501c1e --- /dev/null +++ b/tests/html/html.csv @@ -0,0 +1,10 @@ +action,ms,bytes,lang,code,repeat,minver,comment +before,0,0,q,tsttab:([]time:`timestamp$();sym:`symbol$();val:`long$()),1,,table channel +before,0,0,q,tstfn:{0!select n:count i by sym from tsttab},1,,function channel (like monitor lmchart) +before,0,0,q,.html.init`tsttab`tstfn,1,,register both as pub/sub channels +true,0,0,q,98h=type last .html.sub[`tsttab;`],1,,subscribing to a table still returns an empty copy +true,0,0,q,`sym`time`val~asc cols last .html.sub[`tsttab;`],1,,empty copy has the table's columns +true,0,0,q,()~last .html.sub[`tstfn;`],1,,subscribing to a function channel does not error (#700) +run,0,0,q,.html.wssub each `tsttab`tstfn,1,,websocket subscribe to both like monitor start does +true,0,0,q,all {1=count .html.w[x]} each `tsttab`tstfn,1,,each channel has exactly one subscriber +true,0,0,q,all {.z.w in .html.w[x;;0]} each `tsttab`tstfn,1,,this handle is registered on both channels \ No newline at end of file diff --git a/tests/html/run.sh b/tests/html/run.sh new file mode 100755 index 000000000..2d5f31d56 --- /dev/null +++ b/tests/html/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash +source $KDBTESTS/flagparse.sh +testpath=${KDBTESTS}/html +${RLWRAP} q ${TORQHOME}/torq.q \ + -proctype test -procname test1 \ + -test ${testpath} \ + -testresults ${KDBTESTS}/html/results/ \ + -runtime $run \ + $debug $stop $write $quiet