11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/llm_cost_tracker/calls_controller.rb', line 11
def index
@sort = params[:sort].to_s
scope = Dashboard::Filter.call(params: params)
scope = scope.unknown_pricing if @sort == "unknown_pricing"
ordered_scope = scope.order(Arel.sql(calls_order(@sort)))
@latency_available = LlmApiCall.latency_column?
respond_to do |format|
format.html do
@page = Pagination.call(params)
@calls_count = scope.count
@calls = ordered_scope.limit(@page.limit).offset(@page.offset).to_a
end
format.csv do
send_data render_csv(ordered_scope.limit(CSV_EXPORT_LIMIT)),
type: "text/csv",
disposition: %(attachment; filename="llm_calls_#{Time.now.utc.strftime('%Y%m%d_%H%M%S')}.csv")
end
end
end
|