Class: Textus::Handlers::Read::AuditEntries

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/handlers/read/audit_entries.rb

Instance Method Summary collapse

Constructor Details

#initialize(manifest:, audit_log:) ⇒ AuditEntries

Returns a new instance of AuditEntries.



5
6
7
8
# File 'lib/textus/handlers/read/audit_entries.rb', line 5

def initialize(manifest:, audit_log:)
  @manifest = manifest
  @audit_log = audit_log
end

Instance Method Details

#call(command, _call) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/textus/handlers/read/audit_entries.rb', line 10

def call(command, _call)
  cursor_check = check_cursor_expiry(command.seq_since)
  return cursor_check if cursor_check

  rows = @audit_log.scan(
    seq_since: command.seq_since,
    key: command.key, role: command.role, verb: command.verb,
    correlation_id: command.correlation_id, limit: command.limit
  ).select do |row|
    next false if command.lane && !key_in_lane?(row["key"], command.lane)
    next false if command.since && (row["ts"].nil? || Time.parse(row["ts"]) < command.since)

    true
  end
  Value::Result.success(rows)
end