Class: Rubino::API::Operations::Memory::IndexOperation
- Inherits:
-
Object
- Object
- Rubino::API::Operations::Memory::IndexOperation
- Defined in:
- lib/rubino/api/operations/memory/index_operation.rb
Overview
GET /v1/memory Lists stored facts from the active memory backend, newest first.
‘?q=` filters to facts whose content matches the query (case-insensitive substring). The match is applied at the API layer over the backend’s admin #list so it works identically for every backend — the backends’ own #retrieve is session/turn-relevance scoped and char-budget capped, which is the wrong shape for a flat admin listing.
‘?limit=` / `?offset=` paginate the (optionally filtered) result.
Constant Summary collapse
- DEFAULT_LIMIT =
50- MAX_LIMIT =
200- WINDOW =
Window pulled from the backend before filter+paginate. Generous enough to page through a normal store; the backend keeps its own newest-first ordering.
1000
Class Method Summary collapse
Instance Method Summary collapse
- #call(request) ⇒ Object
-
#initialize(backend: nil) ⇒ IndexOperation
constructor
Accepts an alternate backend for tests.
Constructor Details
#initialize(backend: nil) ⇒ IndexOperation
Accepts an alternate backend for tests.
30 31 32 |
# File 'lib/rubino/api/operations/memory/index_operation.rb', line 30 def initialize(backend: nil) @backend = backend || ::Rubino::Memory::Backends.build end |
Class Method Details
.call(request) ⇒ Object
25 26 27 |
# File 'lib/rubino/api/operations/memory/index_operation.rb', line 25 def self.call(request) new.call(request) end |
Instance Method Details
#call(request) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubino/api/operations/memory/index_operation.rb', line 34 def call(request) limit = clamp(request.query["limit"], DEFAULT_LIMIT, MAX_LIMIT) offset = [request.query["offset"].to_i, 0].max q = request.query["q"].to_s.strip rows = @backend.list(limit: WINDOW) rows = filter(rows, q) unless q.empty? page = rows.slice(offset, limit) || [] [200, { memory: page.map { |row| Serializer.call(row) } }] end |