qodex-rails 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9be5a381de2a7b86049cbaa9febd701729d429a08cf467a71b3b6ff963b1ee49
4
- data.tar.gz: 21975c62120e9b4a2c591e2253da5e510ad554babb53c7ae38dfd2419132a44a
3
+ metadata.gz: 37bec67a7b6e132899a672b96d6580e22c3fe0937888cf62b227c11de157b6ae
4
+ data.tar.gz: 4786488f646d75452ab083f90eca0b26dd97a6a3ba35c1406ae4e42ae392caf5
5
5
  SHA512:
6
- metadata.gz: a0bfaf78e17ff909346b5471731a7ae03a92ca06a9f1f1d179bfedb98bb4324268508edeb6ead23dc2820f5b4dfbb098dfa857deac804565d0baf906dfe5b27f
7
- data.tar.gz: 4c42c05445f578b0eec502d447e789ff1362ea07b83c7e93a47722031f39c8ce656a502a41fa6c5cfc46fb5b4aac04dd8cb1bed63734c13b8dfbe1e0d18688cc
6
+ metadata.gz: '08654fc0a2d2901005831a7156ccbcfa7eb58c01645235bbcf90b5bfa98e8270be9c295c59c6cbb3296fcac2eb88867e256cee3d80dffa5383044ffd610c7f06'
7
+ data.tar.gz: 74f481441fabd88e32392327cc762ec74464c0cf9751399c1047e8c70e0354a2a61a74707df9eb3fa095e05d0e79ebaf71864adf929f48062c1b514fa3064389
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Qodex
4
4
  module Rails
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.6"
6
6
  end
7
7
  end
@@ -17,7 +17,7 @@ module QodexRails
17
17
  end
18
18
 
19
19
  # Print the initializer keys to the output
20
- Rails.logger.info "QodexRails Initializer Keys: Collection Name: #{QodexRails.configuration.collection_name}, API Key: #{QodexRails.configuration.api_key}"
20
+ # Rails.logger.info "QodexRails Initializer Keys: Collection Name: #{QodexRails.configuration.collection_name}, API Key: #{QodexRails.configuration.api_key}"
21
21
 
22
22
  start_time = Time.now
23
23
 
@@ -37,16 +37,19 @@ module QodexRails
37
37
  logs = {
38
38
  collection_name: QodexRails.configuration.collection_name,
39
39
  api_key: QodexRails.configuration.api_key,
40
- apis: [{
41
- body: response_body,
40
+ api: {
41
+ time_spent: (end_time - start_time).to_i,
42
+ body: request_body,
43
+ response_body: response_body,
42
44
  body_type: 'none-type',
43
45
  request_type: request.request_method,
44
46
  timestamp: Time.now.to_i,
45
47
  url: request.url,
46
48
  status: status,
47
- headers: extract_headers(headers),
49
+ headers: extract_request_headers(env),
50
+ response_headers: extract_headers(headers),
48
51
  params: request.params # Using Rails' parameter filtering
49
- }]
52
+ }
50
53
  }
51
54
 
52
55
  # Send the logs to the external API
@@ -57,6 +60,12 @@ module QodexRails
57
60
 
58
61
  private
59
62
 
63
+ def extract_request_headers(env)
64
+ env.select { |k, v| k.start_with?('HTTP_') }
65
+ .map { |pair| [pair[0].sub(/^HTTP_/, ''), pair[1]] }
66
+ .map { |pair| [pair[0].split('_').collect(&:capitalize).join('-'), pair[1]] }
67
+ end
68
+
60
69
  def extract_body(response)
61
70
  body = ""
62
71
  response.each { |part| body << part } if response.respond_to?(:each)
@@ -68,7 +77,7 @@ module QodexRails
68
77
  end
69
78
 
70
79
  def send_to_api(logs)
71
- uri = URI("https://api.app.qodex.ai/api/v1/collections/create_with_folder/#{QodexRails.configuration.api_key}")
80
+ uri = URI("https://api.app.qodex.ai/api/v1/collections/create_sample_data/#{QodexRails.configuration.api_key}")
72
81
  request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
73
82
  request.body = JSON.generate(logs)
74
83
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
@@ -76,7 +85,7 @@ module QodexRails
76
85
  end
77
86
 
78
87
  # Optionally log the response from the external API
79
- Rails.logger.info "URI: #{uri}, API Response: #{response.body}" if response
88
+ # Rails.logger.info "URI: #{uri}, API Response: #{response.body}" if response
80
89
  end
81
90
  end
82
91
  end
@@ -1,3 +1,3 @@
1
1
  module QodexRails
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qodex-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - sid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-02 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Intercept your rails application to power Qodex.ai AI copilot.
14
14
  email:
@@ -33,6 +33,9 @@ files:
33
33
  - qodex-rails-0.1.0.gem
34
34
  - qodex-rails-0.1.1.gem
35
35
  - qodex-rails-0.1.2.gem
36
+ - qodex-rails-0.1.3.gem
37
+ - qodex-rails-0.1.4.gem
38
+ - qodex-rails-0.1.5.gem
36
39
  - sig/qodex/rails.rbs
37
40
  homepage: https://qodex.ai
38
41
  licenses: