qodex-rails 0.1.11 → 0.1.13

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: c8e7c8249409adc8de47a8555086b640d715b3efa3fb674a6c816330cfa92002
4
- data.tar.gz: e6cbd949bfe1859b150e00b14d310d549e68fa018bad5a12eefa6d14d7adb5fc
3
+ metadata.gz: 53f423fa70f86f62f2a1a68fd591468b03b62e5f81792539fd012ee4a10bac80
4
+ data.tar.gz: 7d1a50e23f1bf56ca65120f66b41871e4de476bfe55359415f528e0931e38a4a
5
5
  SHA512:
6
- metadata.gz: ef9e17cbe5f8d6899c13b28221d673dc90597232501fcb37aa8d7a4c1e5c67706312d38af792618d9f6825803481ee8847b35b936c0e3b501e1c4feb8e40fb35
7
- data.tar.gz: bfd3cbfec0187b9cb6dcd457ec5fdf5733dfe641b2327600eae950c2a8e5da64ee8092417d1da52623bc60171302daa43505f320d00193c5d96b0222d71f9310
6
+ metadata.gz: 6e7394d3f7afa7297acf0cff2e8cce1b887b3e49e03a9a0df009ea39be41e712858bc34d2ad154f18bc07e3037c1cc1d43aa1dbab618cf929be9bc427461737b
7
+ data.tar.gz: f136cf35b976b3aa138dd03f28fc4a93aa463910cdc05cb5444009caf3370a7408315311d6c4ef3e3c7c647ba14055f54f7a2abc19161262bd035a2228ca1d87
data/README.md CHANGED
@@ -22,7 +22,8 @@ If bundler is not being used to manage dependencies, install the gem by executin
22
22
  # Your configuration settings for qodex-rails in the staging environment
23
23
  project_name = Rails.application.class.module_parent_name rescue 'qodex'
24
24
  config.collection_name = "#{project_name}-#{Rails.env}" # Name of the collection where logs will be stored
25
- config.enabled_in_production = false # Set to true to enable in production
25
+ config.allowed_environments = ['staging', 'production'] # Default value is staging if not set. Add production to enable in production
26
+ config.frequency = 'high' #default value is medium. to control the speed of the logs processing
26
27
  config.api_key = 'Your API Key'
27
28
  end
28
29
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Qodex
4
4
  module Rails
5
- VERSION = "0.1.11"
5
+ VERSION = "0.1.13"
6
6
  end
7
7
  end
@@ -1,11 +1,13 @@
1
1
  module QodexRails
2
2
  class Configuration
3
- attr_accessor :collection_name, :api_key, :enabled_in_production
3
+ attr_accessor :collection_name, :api_key, :allowed_environments, :frequency, :api_host
4
4
 
5
5
  def initialize
6
6
  @collection_name = nil
7
7
  @api_key = nil
8
- @enabled_in_production = false
8
+ @allowed_environments = ['staging']
9
+ @frequency = 'medium'
10
+ @api_host = nil
9
11
  end
10
12
  end
11
13
  end
@@ -7,14 +7,14 @@ module QodexRails
7
7
  def initialize(app)
8
8
  @app = app
9
9
  @mutex = Mutex.new # Mutex for thread-safe logging
10
+ @allowed_environments = QodexRails.configuration.allowed_environments || ['staging']
11
+ @frequency = QodexRails.configuration.frequency || 'low'
10
12
  end
11
13
 
12
14
  def call(env)
13
15
 
14
- is_staging = Rails.env.staging?
15
- enabled_in_production = Rails.env.production? && QodexRails.configuration.enabled_in_production
16
-
17
- return @app.call(env) unless is_staging || enabled_in_production
16
+ # Check if the current environment is allowed
17
+ return @app.call(env) unless @allowed_environments.include?(Rails.env)
18
18
 
19
19
  # Exit early if collection_name or api_key are not configured
20
20
  unless QodexRails.configuration.collection_name && QodexRails.configuration.api_key
@@ -22,23 +22,32 @@ module QodexRails
22
22
  return @app.call(env)
23
23
  end
24
24
 
25
+ # Decide whether to log based on frequency setting
26
+ random_number = rand(20) + 1
27
+ case @frequency
28
+ when 'low'
29
+ return @app.call(env) unless random_number == 1
30
+ when 'medium'
31
+ return @app.call(env) unless random_number <= 4
32
+ end
33
+
25
34
  # Print the initializer keys to the output
26
35
  # Rails.logger.info "QodexRails Initializer Keys: Collection Name: #{QodexRails.configuration.collection_name}, API Key: #{QodexRails.configuration.api_key}"
27
36
 
28
37
  start_time = Time.now
29
-
38
+
30
39
  # Capture the request details
31
40
  request = Rack::Request.new(env)
32
41
  request_body = request.body.read
33
42
  request.body.rewind
34
-
43
+
35
44
  status, headers, response = @app.call(env)
36
-
45
+
37
46
  end_time = Time.now
38
47
 
39
48
  # Capture the response details
40
49
  response_body = extract_body(response)
41
-
50
+
42
51
  # Construct the logs
43
52
  logs = {
44
53
  collection_name: QodexRails.configuration.collection_name,
@@ -84,7 +93,8 @@ module QodexRails
84
93
  end
85
94
 
86
95
  def send_to_api(logs)
87
- uri = URI("https://api.app.qodex.ai/api/v1/collections/create_sample_data/#{QodexRails.configuration.api_key}")
96
+ api_host = QodexRails.configuration.api_host || 'https://api.app.qodex.ai'
97
+ uri = URI("#{api_host}/api/v1/collections/create_sample_data/#{QodexRails.configuration.api_key}")
88
98
  request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
89
99
  request.body = JSON.generate(logs)
90
100
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
@@ -1,3 +1,3 @@
1
1
  module QodexRails
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.13"
3
3
  end
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.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - sid
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-11 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Intercept your rails application to power Qodex.ai AI copilot.
14
14
  email:
@@ -30,15 +30,7 @@ files:
30
30
  - lib/qodex-rails/version.rb
31
31
  - lib/qodex/rails.rb
32
32
  - lib/qodex/rails/version.rb
33
- - qodex-rails-0.1.0.gem
34
- - qodex-rails-0.1.1.gem
35
- - qodex-rails-0.1.10.gem
36
- - qodex-rails-0.1.2.gem
37
- - qodex-rails-0.1.3.gem
38
- - qodex-rails-0.1.4.gem
39
- - qodex-rails-0.1.5.gem
40
- - qodex-rails-0.1.8.gem
41
- - qodex-rails-0.1.9.gem
33
+ - qodex-rails-0.1.12.gem
42
34
  - sig/qodex/rails.rbs
43
35
  homepage: https://qodex.ai
44
36
  licenses:
@@ -48,7 +40,7 @@ metadata:
48
40
  homepage_uri: https://qodex.ai
49
41
  source_code_uri: https://github.com/qodex-ai/qodex-rails
50
42
  changelog_uri: https://github.com/qodex-ai/qodex-rails
51
- post_install_message:
43
+ post_install_message:
52
44
  rdoc_options: []
53
45
  require_paths:
54
46
  - lib
@@ -63,8 +55,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
55
  - !ruby/object:Gem::Version
64
56
  version: '0'
65
57
  requirements: []
66
- rubygems_version: 3.0.3.1
67
- signing_key:
58
+ rubygems_version: 3.5.3
59
+ signing_key:
68
60
  specification_version: 4
69
61
  summary: Intercept your rails application to power Qodex.ai AI copilot.
70
62
  test_files: []
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file