- # +id+ the id of the most recent row in the log table, may be nil
- def push_events ws, id = nil
- begin
- # 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")
-
- if ws.last_log_id
- # Client is only interested in log rows that are newer than the
- # last log row seen by the client.
- logs = logs.where("logs.id > ?", ws.last_log_id)
- elsif id
- # No last log id, so only look at the most recently changed row
- logs = logs.where("logs.id = ?", id.to_i)
- else
- return
- end
+ # +notify_id+ the id of the most recent row in the log table, may be nil
+ #
+ # This accepts a websocket and a notify_id (this is the row id from Postgres
+ # LISTEN/NOTIFY, it may be nil if called from somewhere else)
+ #
+ # It queries the database for log rows that are either
+ # a) greater than ws.last_log_id, which is the last log id which was a candidate to be sent out
+ # b) if ws.last_log_id is nil, then it queries the row notify_id
+ #
+ # Regular Arvados permissions are applied using readable_by() and filters using record_filters().
+ def push_events ws, notify_id
+ begin
+ # 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")