32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/profiler/mcp/tools/get_profile_ajax.rb', line 32
def self.format_ajax(profile, ajax_data)
lines = []
lines << "# AJAX Analysis: #{profile.token}\n"
lines << "**Request:** #{profile.method} #{profile.path}"
lines << "**Total AJAX Requests:** #{ajax_data['total_requests']}"
lines << "**Total Duration:** #{ajax_data['total_duration'].round(2)} ms\n"
if ajax_data["by_method"] && !ajax_data["by_method"].empty?
lines << "## By Method"
ajax_data["by_method"].each { |method, count| lines << "- **#{method}**: #{count}" }
lines << ""
end
if ajax_data["by_status"] && !ajax_data["by_status"].empty?
lines << "## By Status"
ajax_data["by_status"].each { |status, count| lines << "- **#{status}**: #{count}" }
lines << ""
end
if ajax_data["requests"] && !ajax_data["requests"].empty?
lines << "## Request List"
ajax_data["requests"].each_with_index do |req, index|
lines << "\n### Request #{index + 1}"
lines << "- **Method:** #{req['method']}"
lines << "- **Path:** #{req['path']}"
lines << "- **Status:** #{req['status']}"
lines << "- **Duration:** #{req['duration'].round(2)} ms"
lines << "- **Token:** #{req['token']}" if req['token']
lines << "- **Started At:** #{req['started_at']}" if req['started_at']
end
lines << ""
end
lines.join("\n")
end
|