Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/common/html.q
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/visualisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions tests/html/html.csv
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions tests/html/run.sh
Original file line number Diff line number Diff line change
@@ -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