QueryWise 0.2.0

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.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +45 -0
  3. data/CLOUD_RUN_README.md +263 -0
  4. data/DOCKER_README.md +327 -0
  5. data/Dockerfile +69 -0
  6. data/Dockerfile.cloudrun +76 -0
  7. data/Dockerfile.dev +36 -0
  8. data/GEM_Gemfile +16 -0
  9. data/GEM_README.md +421 -0
  10. data/GEM_Rakefile +10 -0
  11. data/GEM_gitignore +137 -0
  12. data/LICENSE.txt +21 -0
  13. data/PUBLISHING_GUIDE.md +269 -0
  14. data/README.md +392 -0
  15. data/app/controllers/api/v1/analysis_controller.rb +340 -0
  16. data/app/controllers/api/v1/api_keys_controller.rb +83 -0
  17. data/app/controllers/api/v1/base_controller.rb +93 -0
  18. data/app/controllers/api/v1/health_controller.rb +86 -0
  19. data/app/controllers/application_controller.rb +2 -0
  20. data/app/controllers/concerns/.keep +0 -0
  21. data/app/jobs/application_job.rb +7 -0
  22. data/app/mailers/application_mailer.rb +4 -0
  23. data/app/models/app_profile.rb +18 -0
  24. data/app/models/application_record.rb +3 -0
  25. data/app/models/concerns/.keep +0 -0
  26. data/app/models/optimization_suggestion.rb +44 -0
  27. data/app/models/query_analysis.rb +47 -0
  28. data/app/models/query_pattern.rb +55 -0
  29. data/app/services/missing_index_detector_service.rb +244 -0
  30. data/app/services/n_plus_one_detector_service.rb +177 -0
  31. data/app/services/slow_query_analyzer_service.rb +225 -0
  32. data/app/services/sql_parser_service.rb +352 -0
  33. data/app/validators/query_data_validator.rb +96 -0
  34. data/app/views/layouts/mailer.html.erb +13 -0
  35. data/app/views/layouts/mailer.text.erb +1 -0
  36. data/app.yaml +109 -0
  37. data/cloudbuild.yaml +47 -0
  38. data/config/application.rb +32 -0
  39. data/config/boot.rb +4 -0
  40. data/config/cable.yml +17 -0
  41. data/config/cache.yml +16 -0
  42. data/config/credentials.yml.enc +1 -0
  43. data/config/database.yml +69 -0
  44. data/config/deploy.yml +116 -0
  45. data/config/environment.rb +5 -0
  46. data/config/environments/development.rb +70 -0
  47. data/config/environments/production.rb +87 -0
  48. data/config/environments/test.rb +53 -0
  49. data/config/initializers/cors.rb +16 -0
  50. data/config/initializers/filter_parameter_logging.rb +8 -0
  51. data/config/initializers/inflections.rb +16 -0
  52. data/config/locales/en.yml +31 -0
  53. data/config/master.key +1 -0
  54. data/config/puma.rb +41 -0
  55. data/config/puma_cloudrun.rb +48 -0
  56. data/config/queue.yml +18 -0
  57. data/config/recurring.yml +15 -0
  58. data/config/routes.rb +28 -0
  59. data/config/storage.yml +34 -0
  60. data/config.ru +6 -0
  61. data/db/cable_schema.rb +11 -0
  62. data/db/cache_schema.rb +14 -0
  63. data/db/migrate/20250818214709_create_app_profiles.rb +13 -0
  64. data/db/migrate/20250818214731_create_query_analyses.rb +22 -0
  65. data/db/migrate/20250818214740_create_query_patterns.rb +22 -0
  66. data/db/migrate/20250818214805_create_optimization_suggestions.rb +20 -0
  67. data/db/queue_schema.rb +129 -0
  68. data/db/schema.rb +79 -0
  69. data/db/seeds.rb +9 -0
  70. data/init.sql +9 -0
  71. data/lib/query_optimizer_client/client.rb +176 -0
  72. data/lib/query_optimizer_client/configuration.rb +43 -0
  73. data/lib/query_optimizer_client/generators/install_generator.rb +43 -0
  74. data/lib/query_optimizer_client/generators/templates/README +46 -0
  75. data/lib/query_optimizer_client/generators/templates/analysis_job.rb +84 -0
  76. data/lib/query_optimizer_client/generators/templates/initializer.rb +30 -0
  77. data/lib/query_optimizer_client/middleware.rb +126 -0
  78. data/lib/query_optimizer_client/railtie.rb +37 -0
  79. data/lib/query_optimizer_client/tasks.rake +228 -0
  80. data/lib/query_optimizer_client/version.rb +5 -0
  81. data/lib/query_optimizer_client.rb +48 -0
  82. data/lib/tasks/.keep +0 -0
  83. data/public/robots.txt +1 -0
  84. data/query_optimizer_client.gemspec +60 -0
  85. data/script/.keep +0 -0
  86. data/storage/.keep +0 -0
  87. data/storage/development.sqlite3 +0 -0
  88. data/storage/test.sqlite3 +0 -0
  89. data/vendor/.keep +0 -0
  90. metadata +265 -0
data/app.yaml ADDED
@@ -0,0 +1,109 @@
1
+ # Google Cloud Run service configuration
2
+ # This file defines the Cloud Run service settings
3
+
4
+ apiVersion: serving.knative.dev/v1
5
+ kind: Service
6
+ metadata:
7
+ name: query-optimizer-api
8
+ annotations:
9
+ run.googleapis.com/ingress: all
10
+ run.googleapis.com/execution-environment: gen2
11
+ spec:
12
+ template:
13
+ metadata:
14
+ annotations:
15
+ # Scaling configuration
16
+ autoscaling.knative.dev/minScale: "0"
17
+ autoscaling.knative.dev/maxScale: "10"
18
+
19
+ # Resource allocation
20
+ run.googleapis.com/memory: "512Mi"
21
+ run.googleapis.com/cpu: "1"
22
+
23
+ # Timeout configuration
24
+ run.googleapis.com/timeout: "300"
25
+
26
+ # Cloud SQL connection
27
+ run.googleapis.com/cloudsql-instances: PROJECT_ID:us-central1:query-optimizer-db
28
+
29
+ # VPC connector (if needed)
30
+ # run.googleapis.com/vpc-access-connector: projects/PROJECT_ID/locations/us-central1/connectors/default
31
+
32
+ spec:
33
+ serviceAccountName: query-optimizer@PROJECT_ID.iam.gserviceaccount.com
34
+ containerConcurrency: 80
35
+ timeoutSeconds: 300
36
+
37
+ containers:
38
+ - image: gcr.io/PROJECT_ID/query-optimizer-api:latest
39
+ ports:
40
+ - name: http1
41
+ containerPort: 8080
42
+
43
+ env:
44
+ - name: RAILS_ENV
45
+ value: "production"
46
+ - name: PORT
47
+ value: "8080"
48
+ - name: RAILS_LOG_TO_STDOUT
49
+ value: "true"
50
+ - name: RAILS_SERVE_STATIC_FILES
51
+ value: "true"
52
+
53
+ # Database configuration
54
+ - name: DATABASE_URL
55
+ value: "postgresql://rails:PASSWORD@/query_optimizer_production?host=/cloudsql/PROJECT_ID:us-central1:query-optimizer-db"
56
+
57
+ # Secrets from Secret Manager
58
+ - name: RAILS_MASTER_KEY
59
+ valueFrom:
60
+ secretKeyRef:
61
+ name: rails-master-key
62
+ key: latest
63
+
64
+ - name: SECRET_KEY_BASE
65
+ valueFrom:
66
+ secretKeyRef:
67
+ name: rails-master-key
68
+ key: latest
69
+
70
+ resources:
71
+ limits:
72
+ memory: "512Mi"
73
+ cpu: "1000m"
74
+ requests:
75
+ memory: "256Mi"
76
+ cpu: "100m"
77
+
78
+ # Health check
79
+ livenessProbe:
80
+ httpGet:
81
+ path: /api/v1/health
82
+ port: 8080
83
+ initialDelaySeconds: 30
84
+ periodSeconds: 30
85
+ timeoutSeconds: 5
86
+ failureThreshold: 3
87
+
88
+ readinessProbe:
89
+ httpGet:
90
+ path: /api/v1/health
91
+ port: 8080
92
+ initialDelaySeconds: 10
93
+ periodSeconds: 10
94
+ timeoutSeconds: 5
95
+ failureThreshold: 3
96
+
97
+ # Startup probe for slow starts
98
+ startupProbe:
99
+ httpGet:
100
+ path: /api/v1/health
101
+ port: 8080
102
+ initialDelaySeconds: 10
103
+ periodSeconds: 10
104
+ timeoutSeconds: 5
105
+ failureThreshold: 30
106
+
107
+ traffic:
108
+ - percent: 100
109
+ latestRevision: true
data/cloudbuild.yaml ADDED
@@ -0,0 +1,47 @@
1
+ # Google Cloud Build configuration for Query Optimizer API
2
+ steps:
3
+ # Build the container image
4
+ - name: 'gcr.io/cloud-builders/docker'
5
+ args: [
6
+ 'build',
7
+ '-t', 'gcr.io/$PROJECT_ID/query-optimizer-api:$COMMIT_SHA',
8
+ '-t', 'gcr.io/$PROJECT_ID/query-optimizer-api:latest',
9
+ '.'
10
+ ]
11
+
12
+ # Push the container image to Container Registry
13
+ - name: 'gcr.io/cloud-builders/docker'
14
+ args: ['push', 'gcr.io/$PROJECT_ID/query-optimizer-api:$COMMIT_SHA']
15
+
16
+ - name: 'gcr.io/cloud-builders/docker'
17
+ args: ['push', 'gcr.io/$PROJECT_ID/query-optimizer-api:latest']
18
+
19
+ # Deploy to Cloud Run
20
+ - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
21
+ entrypoint: gcloud
22
+ args: [
23
+ 'run', 'deploy', 'query-optimizer-api',
24
+ '--image', 'gcr.io/$PROJECT_ID/query-optimizer-api:$COMMIT_SHA',
25
+ '--region', 'us-central1',
26
+ '--platform', 'managed',
27
+ '--allow-unauthenticated',
28
+ '--port', '80',
29
+ '--memory', '512Mi',
30
+ '--cpu', '1',
31
+ '--max-instances', '10',
32
+ '--set-env-vars', 'RAILS_ENV=production',
33
+ '--set-cloudsql-instances', '$PROJECT_ID:us-central1:query-optimizer-db'
34
+ ]
35
+
36
+ # Store images in Container Registry
37
+ images:
38
+ - 'gcr.io/$PROJECT_ID/query-optimizer-api:$COMMIT_SHA'
39
+ - 'gcr.io/$PROJECT_ID/query-optimizer-api:latest'
40
+
41
+ # Build options
42
+ options:
43
+ logging: CLOUD_LOGGING_ONLY
44
+ machineType: 'E2_HIGHCPU_8'
45
+
46
+ # Timeout for the entire build
47
+ timeout: '1200s'
@@ -0,0 +1,32 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module QueryOptimizerApi
10
+ class Application < Rails::Application
11
+ # Initialize configuration defaults for originally generated Rails version.
12
+ config.load_defaults 8.0
13
+
14
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
15
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
16
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
17
+ config.autoload_lib(ignore: %w[assets tasks])
18
+
19
+ # Configuration for the application, engines, and railties goes here.
20
+ #
21
+ # These settings can be overridden in specific environments using the files
22
+ # in config/environments, which are processed later.
23
+ #
24
+ # config.time_zone = "Central Time (US & Canada)"
25
+ # config.eager_load_paths << Rails.root.join("extras")
26
+
27
+ # Only loads a smaller set of middleware suitable for API only apps.
28
+ # Middleware like session, flash, cookies can be added back manually.
29
+ # Skip views, helpers and assets when generating a new resource.
30
+ config.api_only = true
31
+ end
32
+ end
data/config/boot.rb ADDED
@@ -0,0 +1,4 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
data/config/cable.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Async adapter only works within the same process, so for manually triggering cable updates from a console,
2
+ # and seeing results in the browser, you must do so from the web console (running inside the dev process),
3
+ # not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
4
+ # to make the web console appear.
5
+ development:
6
+ adapter: async
7
+
8
+ test:
9
+ adapter: test
10
+
11
+ production:
12
+ adapter: solid_cable
13
+ connects_to:
14
+ database:
15
+ writing: cable
16
+ polling_interval: 0.1.seconds
17
+ message_retention: 1.day
data/config/cache.yml ADDED
@@ -0,0 +1,16 @@
1
+ default: &default
2
+ store_options:
3
+ # Cap age of oldest cache entry to fulfill retention policies
4
+ # max_age: <%= 60.days.to_i %>
5
+ max_size: <%= 256.megabytes %>
6
+ namespace: <%= Rails.env %>
7
+
8
+ development:
9
+ <<: *default
10
+
11
+ test:
12
+ <<: *default
13
+
14
+ production:
15
+ database: cache
16
+ <<: *default
@@ -0,0 +1 @@
1
+ Ar7RQxePiYJQh6S8/tJIdDxGrSbA88iwncLVYAdXhy9r+5u3L3B1J7siGwf6O84CKw8FALcDH1B4hA2G2+ChE8KmSNOd7ELuI0hSi+62OUzGviY5W0M0wvDdzfcBNgcKonSMxGaqb4rtjWCir/iJT4ihvGRDzLY/ljjMWoKnvdzKXTNm1VqMlCduXptYMl2qmNXzJkgHAyf+1yhrIOi7BrOUi1nOufVX4OBJkG+YBnOvA8VzI+8oZEtX09PhtT5MoV1byTVBvgpf9Tdw5d4uRQFkwU731Rba5LbAd6UDvJ3rqWsj6xn1OWciVYW043qV8h6JqDwQLVkpLzG14PRJduTft6wB8B1i/Nrq1H+LmdaSvEBPCaR6Z/Rk57vK09t7kaPtXtF57dazF1EwKduIuUavl0oT6MWtpOBH8SvFYHJQjlBpgHTHfEf3IQ8G2rTHKHu0jrmz6AirMNqWqsbfDjpk0YknxtXDFdUboCBaimDNj1R+9zz2yIvj--RnerCVR+XSOxvaaj--1Avg97H8bjVQX+r7+kSM3w==
@@ -0,0 +1,69 @@
1
+ # PostgreSQL. Versions 9.3 and up are supported.
2
+ #
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On macOS with Homebrew:
6
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
+ # On Windows:
8
+ # gem install pg
9
+ # Choose the win32 build.
10
+ # Install PostgreSQL and put its /bin directory on your path.
11
+ #
12
+ # Configure Using Gemfile
13
+ # gem "pg"
14
+ #
15
+ default: &default
16
+ adapter: sqlite3
17
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
18
+ timeout: 5000
19
+
20
+
21
+ development:
22
+ <<: *default
23
+ database: storage/development.sqlite3
24
+
25
+ # Warning: The database defined as "test" will be erased and
26
+ # re-generated from your development database when you run "rake".
27
+ # Do not set this db to the same as development or production.
28
+ test:
29
+ <<: *default
30
+ database: storage/test.sqlite3
31
+
32
+ # As with config/credentials.yml, you never want to store sensitive information,
33
+ # like your database password, in your source code. If your source code is
34
+ # ever seen by anyone, they now have access to your database.
35
+ #
36
+ # Instead, provide the password or a full connection URL as an environment
37
+ # variable when you boot the app. For example:
38
+ #
39
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
40
+ #
41
+ # If the connection URL is provided in the special DATABASE_URL environment
42
+ # variable, Rails will automatically merge its configuration values on top of
43
+ # the values provided in this file. Alternatively, you can specify a connection
44
+ # URL environment variable explicitly:
45
+ #
46
+ # production:
47
+ # url: <%= ENV["MY_APP_DATABASE_URL"] %>
48
+ #
49
+ # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
50
+ # for a full overview on how database connection configuration can be specified.
51
+ #
52
+ production:
53
+ primary: &primary_production
54
+ <<: *default
55
+ database: query_optimizer_api_production
56
+ username: query_optimizer_api
57
+ password: <%= ENV["QUERY_OPTIMIZER_API_DATABASE_PASSWORD"] %>
58
+ cache:
59
+ <<: *primary_production
60
+ database: query_optimizer_api_production_cache
61
+ migrations_paths: db/cache_migrate
62
+ queue:
63
+ <<: *primary_production
64
+ database: query_optimizer_api_production_queue
65
+ migrations_paths: db/queue_migrate
66
+ cable:
67
+ <<: *primary_production
68
+ database: query_optimizer_api_production_cable
69
+ migrations_paths: db/cable_migrate
data/config/deploy.yml ADDED
@@ -0,0 +1,116 @@
1
+ # Name of your application. Used to uniquely configure containers.
2
+ service: query_optimizer_api
3
+
4
+ # Name of the container image.
5
+ image: your-user/query_optimizer_api
6
+
7
+ # Deploy to these servers.
8
+ servers:
9
+ web:
10
+ - 192.168.0.1
11
+ # job:
12
+ # hosts:
13
+ # - 192.168.0.1
14
+ # cmd: bin/jobs
15
+
16
+ # Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server.
17
+ # Remove this section when using multiple web servers and ensure you terminate SSL at your load balancer.
18
+ #
19
+ # Note: If using Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
20
+ proxy:
21
+ ssl: true
22
+ host: app.example.com
23
+
24
+ # Credentials for your image host.
25
+ registry:
26
+ # Specify the registry server, if you're not using Docker Hub
27
+ # server: registry.digitalocean.com / ghcr.io / ...
28
+ username: your-user
29
+
30
+ # Always use an access token rather than real password when possible.
31
+ password:
32
+ - KAMAL_REGISTRY_PASSWORD
33
+
34
+ # Inject ENV variables into containers (secrets come from .kamal/secrets).
35
+ env:
36
+ secret:
37
+ - RAILS_MASTER_KEY
38
+ clear:
39
+ # Run the Solid Queue Supervisor inside the web server's Puma process to do jobs.
40
+ # When you start using multiple servers, you should split out job processing to a dedicated machine.
41
+ SOLID_QUEUE_IN_PUMA: true
42
+
43
+ # Set number of processes dedicated to Solid Queue (default: 1)
44
+ # JOB_CONCURRENCY: 3
45
+
46
+ # Set number of cores available to the application on each server (default: 1).
47
+ # WEB_CONCURRENCY: 2
48
+
49
+ # Match this to any external database server to configure Active Record correctly
50
+ # Use query_optimizer_api-db for a db accessory server on same machine via local kamal docker network.
51
+ # DB_HOST: 192.168.0.2
52
+
53
+ # Log everything from Rails
54
+ # RAILS_LOG_LEVEL: debug
55
+
56
+ # Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
57
+ # "bin/kamal logs -r job" will tail logs from the first server in the job section.
58
+ aliases:
59
+ console: app exec --interactive --reuse "bin/rails console"
60
+ shell: app exec --interactive --reuse "bash"
61
+ logs: app logs -f
62
+ dbc: app exec --interactive --reuse "bin/rails dbconsole"
63
+
64
+
65
+ # Use a persistent storage volume for sqlite database files and local Active Storage files.
66
+ # Recommended to change this to a mounted volume path that is backed up off server.
67
+ volumes:
68
+ - "query_optimizer_api_storage:/rails/storage"
69
+
70
+
71
+ # Bridge fingerprinted assets, like JS and CSS, between versions to avoid
72
+ # hitting 404 on in-flight requests. Combines all files from new and old
73
+ # version inside the asset_path.
74
+ asset_path: /rails/public/assets
75
+
76
+ # Configure the image builder.
77
+ builder:
78
+ arch: amd64
79
+
80
+ # # Build image via remote server (useful for faster amd64 builds on arm64 computers)
81
+ # remote: ssh://docker@docker-builder-server
82
+ #
83
+ # # Pass arguments and secrets to the Docker build process
84
+ # args:
85
+ # RUBY_VERSION: 3.2.2
86
+ # secrets:
87
+ # - GITHUB_TOKEN
88
+ # - RAILS_MASTER_KEY
89
+
90
+ # Use a different ssh user than root
91
+ # ssh:
92
+ # user: app
93
+
94
+ # Use accessory services (secrets come from .kamal/secrets).
95
+ # accessories:
96
+ # db:
97
+ # image: mysql:8.0
98
+ # host: 192.168.0.2
99
+ # # Change to 3306 to expose port to the world instead of just local network.
100
+ # port: "127.0.0.1:3306:3306"
101
+ # env:
102
+ # clear:
103
+ # MYSQL_ROOT_HOST: '%'
104
+ # secret:
105
+ # - MYSQL_ROOT_PASSWORD
106
+ # files:
107
+ # - config/mysql/production.cnf:/etc/mysql/my.cnf
108
+ # - db/production.sql:/docker-entrypoint-initdb.d/setup.sql
109
+ # directories:
110
+ # - data:/var/lib/mysql
111
+ # redis:
112
+ # image: redis:7.0
113
+ # host: 192.168.0.2
114
+ # port: 6379
115
+ # directories:
116
+ # - data:/data
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,70 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Make code changes take effect immediately without server restart.
7
+ config.enable_reloading = true
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable server timing.
16
+ config.server_timing = true
17
+
18
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19
+ # Run rails dev:cache to toggle Action Controller caching.
20
+ if Rails.root.join("tmp/caching-dev.txt").exist?
21
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
22
+ else
23
+ config.action_controller.perform_caching = false
24
+ end
25
+
26
+ # Change to :null_store to avoid any caching.
27
+ config.cache_store = :memory_store
28
+
29
+ # Store uploaded files on the local file system (see config/storage.yml for options).
30
+ config.active_storage.service = :local
31
+
32
+ # Don't care if the mailer can't send.
33
+ config.action_mailer.raise_delivery_errors = false
34
+
35
+ # Make template changes take effect immediately.
36
+ config.action_mailer.perform_caching = false
37
+
38
+ # Set localhost to be used by links generated in mailer templates.
39
+ config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
40
+
41
+ # Print deprecation notices to the Rails logger.
42
+ config.active_support.deprecation = :log
43
+
44
+ # Raise an error on page load if there are pending migrations.
45
+ config.active_record.migration_error = :page_load
46
+
47
+ # Highlight code that triggered database queries in logs.
48
+ config.active_record.verbose_query_logs = true
49
+
50
+ # Append comments with runtime information tags to SQL queries in logs.
51
+ config.active_record.query_log_tags_enabled = true
52
+
53
+ # Highlight code that enqueued background job in logs.
54
+ config.active_job.verbose_enqueue_logs = true
55
+
56
+ # Raises error for missing translations.
57
+ # config.i18n.raise_on_missing_translations = true
58
+
59
+ # Annotate rendered view with file names.
60
+ config.action_view.annotate_rendered_view_with_filenames = true
61
+
62
+ # Uncomment if you wish to allow Action Cable access from any origin.
63
+ # config.action_cable.disable_request_forgery_protection = true
64
+
65
+ # Raise error when a before_action's only/except options reference missing actions.
66
+ config.action_controller.raise_on_missing_callback_actions = true
67
+
68
+ # Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
69
+ # config.generators.apply_rubocop_autocorrect_after_generate!
70
+ end
@@ -0,0 +1,87 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Code is not reloaded between requests.
7
+ config.enable_reloading = false
8
+
9
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
10
+ config.eager_load = true
11
+
12
+ # Full error reports are disabled.
13
+ config.consider_all_requests_local = false
14
+
15
+ # Cache assets for far-future expiry since they are all digest stamped.
16
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
17
+
18
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
19
+ # config.asset_host = "http://assets.example.com"
20
+
21
+ # Store uploaded files on the local file system (see config/storage.yml for options).
22
+ config.active_storage.service = :local
23
+
24
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
25
+ config.assume_ssl = true
26
+
27
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
28
+ config.force_ssl = true
29
+
30
+ # Skip http-to-https redirect for the default health check endpoint.
31
+ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
32
+
33
+ # Log to STDOUT with the current request id as a default log tag.
34
+ config.log_tags = [ :request_id ]
35
+ config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
36
+
37
+ # Change to "debug" to log everything (including potentially personally-identifiable information!)
38
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
39
+
40
+ # Prevent health checks from clogging up the logs.
41
+ config.silence_healthcheck_path = "/up"
42
+
43
+ # Don't log any deprecations.
44
+ config.active_support.report_deprecations = false
45
+
46
+ # Replace the default in-process memory cache store with a durable alternative.
47
+ config.cache_store = :solid_cache_store
48
+
49
+ # Replace the default in-process and non-durable queuing backend for Active Job.
50
+ config.active_job.queue_adapter = :solid_queue
51
+ config.solid_queue.connects_to = { database: { writing: :queue } }
52
+
53
+ # Ignore bad email addresses and do not raise email delivery errors.
54
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
55
+ # config.action_mailer.raise_delivery_errors = false
56
+
57
+ # Set host to be used by links generated in mailer templates.
58
+ config.action_mailer.default_url_options = { host: "example.com" }
59
+
60
+ # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
61
+ # config.action_mailer.smtp_settings = {
62
+ # user_name: Rails.application.credentials.dig(:smtp, :user_name),
63
+ # password: Rails.application.credentials.dig(:smtp, :password),
64
+ # address: "smtp.example.com",
65
+ # port: 587,
66
+ # authentication: :plain
67
+ # }
68
+
69
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70
+ # the I18n.default_locale when a translation cannot be found).
71
+ config.i18n.fallbacks = true
72
+
73
+ # Do not dump schema after migrations.
74
+ config.active_record.dump_schema_after_migration = false
75
+
76
+ # Only use :id for inspections in production.
77
+ config.active_record.attributes_for_inspect = [ :id ]
78
+
79
+ # Enable DNS rebinding protection and other `Host` header attacks.
80
+ # config.hosts = [
81
+ # "example.com", # Allow requests from example.com
82
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
83
+ # ]
84
+ #
85
+ # Skip DNS rebinding protection for the default health check endpoint.
86
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
87
+ end
@@ -0,0 +1,53 @@
1
+ # The test environment is used exclusively to run your application's
2
+ # test suite. You never need to work with it otherwise. Remember that
3
+ # your test database is "scratch space" for the test suite and is wiped
4
+ # and recreated between test runs. Don't rely on the data there!
5
+
6
+ Rails.application.configure do
7
+ # Settings specified here will take precedence over those in config/application.rb.
8
+
9
+ # While tests run files are not watched, reloading is not necessary.
10
+ config.enable_reloading = false
11
+
12
+ # Eager loading loads your entire application. When running a single test locally,
13
+ # this is usually not necessary, and can slow down your test suite. However, it's
14
+ # recommended that you enable it in continuous integration systems to ensure eager
15
+ # loading is working properly before deploying your code.
16
+ config.eager_load = ENV["CI"].present?
17
+
18
+ # Configure public file server for tests with cache-control for performance.
19
+ config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
20
+
21
+ # Show full error reports.
22
+ config.consider_all_requests_local = true
23
+ config.cache_store = :null_store
24
+
25
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
26
+ config.action_dispatch.show_exceptions = :rescuable
27
+
28
+ # Disable request forgery protection in test environment.
29
+ config.action_controller.allow_forgery_protection = false
30
+
31
+ # Store uploaded files on the local file system in a temporary directory.
32
+ config.active_storage.service = :test
33
+
34
+ # Tell Action Mailer not to deliver emails to the real world.
35
+ # The :test delivery method accumulates sent emails in the
36
+ # ActionMailer::Base.deliveries array.
37
+ config.action_mailer.delivery_method = :test
38
+
39
+ # Set host to be used by links generated in mailer templates.
40
+ config.action_mailer.default_url_options = { host: "example.com" }
41
+
42
+ # Print deprecation notices to the stderr.
43
+ config.active_support.deprecation = :stderr
44
+
45
+ # Raises error for missing translations.
46
+ # config.i18n.raise_on_missing_translations = true
47
+
48
+ # Annotate rendered view with file names.
49
+ # config.action_view.annotate_rendered_view_with_filenames = true
50
+
51
+ # Raise error when a before_action's only/except options reference missing actions.
52
+ config.action_controller.raise_on_missing_callback_actions = true
53
+ end
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Avoid CORS issues when API is called from the frontend app.
4
+ # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
5
+
6
+ # Read more: https://github.com/cyu/rack-cors
7
+
8
+ Rails.application.config.middleware.insert_before 0, Rack::Cors do
9
+ allow do
10
+ origins "*" # In production, specify allowed origins
11
+
12
+ resource "*",
13
+ headers: :any,
14
+ methods: [:get, :post, :put, :patch, :delete, :options, :head]
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
4
+ # Use this to limit dissemination of sensitive information.
5
+ # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
6
+ Rails.application.config.filter_parameters += [
7
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
8
+ ]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym "RESTful"
16
+ # end