+ # Must have at least one filter set up to receive events
+ if ws.filters.length > 0
+ # Start with log rows readable by user, sorted in ascending order
+ logs = Log.readable_by(ws.user).order("id asc")
+
+ cond_id = nil
+ cond_out = []
+ param_out = []
+
+ if ws.last_log_id
+ # Client is only interested in log rows that are newer than the
+ # last log row seen by the client.
+ cond_id = "logs.id > ?"
+ param_out << ws.last_log_id
+ elsif id
+ # No last log id, so only look at the most recently changed row
+ cond_id = "logs.id = ?"
+ param_out << id.to_i
+ else
+ return
+ end