peak_flow_utils 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/peak_flow_utils/application_controller.rb +6 -1
- data/app/controllers/peak_flow_utils/pings/postgres_connections_controller.rb +9 -0
- data/app/controllers/peak_flow_utils/pings/{sidekiq_pings_controller.rb → sidekiq_controller.rb} +4 -2
- data/config/routes.rb +4 -0
- data/lib/peak_flow_utils.rb +9 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/application_record.rb +0 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/group.rb +0 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/handler.rb +0 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/handler_text.rb +0 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/scanned_file.rb +0 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/translation_key.rb +0 -0
- data/{app/models/peak_flow_utils → lib/peak_flow_utils/models}/translation_value.rb +0 -0
- data/lib/peak_flow_utils/notifier.rb +24 -2
- data/lib/peak_flow_utils/notifier_response.rb +6 -2
- data/lib/peak_flow_utils/version.rb +1 -1
- metadata +11 -17
- data/app/assets/config/peak_flow_utils_manifest.js +0 -2
- data/app/assets/javascripts/peak_flow_utils/application.js +0 -14
- data/app/assets/stylesheets/peak_flow_utils/application.css +0 -15
- data/app/helpers/peak_flow_utils/application_helper.rb +0 -2
- data/app/jobs/peak_flow_utils/application_job.rb +0 -2
- data/app/mailers/peak_flow_utils/application_mailer.rb +0 -4
- data/app/views/layouts/peak_flow_utils/application.html.erb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27b80fe472694a76875b46c4bc5e393e6bf02acb13e4ff2b194e5ce4b61698b7
|
4
|
+
data.tar.gz: 4e4bd827165ad878970df19990af1d80ab229188f7d590464faadb772945b324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11cc3ae6a4bed2cec6209846fbe5463e2133c4a5ff3873a63ef93bec83fbf1a58c90282aa279307dc090e3d1ac30d27bcb93193dc7489914b500939d8a389bb1
|
7
|
+
data.tar.gz: 2b20aedf4ba6b0ae8ad2a6882e8f8664c9212310ce4cd2f555ac6c6436cb5943b6096d23e64502deaf6ea3c02f105e7c941614e1b549e767878a08fe9a4d0080
|
@@ -7,7 +7,12 @@ private
|
|
7
7
|
|
8
8
|
def authenticate
|
9
9
|
authenticate_or_request_with_http_basic do |username, password|
|
10
|
-
|
10
|
+
if ENV["PEAKFLOW_PINGS_USERNAME"].blank? || ENV["PEAKFLOW_PINGS_PASSWORD"].blank?
|
11
|
+
Rails.logger.error "Peakflow utils: Pings called but PEAKFLOW_PINGS_USERNAME or PEAKFLOW_PINGS_PASSWORD wasn't set"
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
username == ENV.fetch("PEAKFLOW_PINGS_USERNAME") && password == ENV.fetch("PEAKFLOW_PINGS_PASSWORD")
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class PeakFlowUtils::Pings::PostgresConnectionsController < PeakFlowUtils::ApplicationController
|
2
|
+
def count
|
3
|
+
postgres_connections_count = ActiveRecord::Base.connection.execute("SELECT SUM(numbackends) AS connections_count FROM pg_stat_database").to_a.first
|
4
|
+
|
5
|
+
render json: {
|
6
|
+
postgres_connections_count: postgres_connections_count.fetch("connections_count")
|
7
|
+
}
|
8
|
+
end
|
9
|
+
end
|
data/app/controllers/peak_flow_utils/pings/{sidekiq_pings_controller.rb → sidekiq_controller.rb}
RENAMED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "sidekiq/api"
|
2
|
+
|
3
|
+
class PeakFlowUtils::Pings::SidekiqController < PeakFlowUtils::ApplicationController
|
4
|
+
def index
|
3
5
|
sidekiq_queue = Sidekiq::Queue.new
|
4
6
|
|
5
7
|
render json: {
|
data/config/routes.rb
CHANGED
data/lib/peak_flow_utils.rb
CHANGED
@@ -5,6 +5,7 @@ require "service_pattern"
|
|
5
5
|
|
6
6
|
module PeakFlowUtils
|
7
7
|
path = "#{File.dirname(__FILE__)}/peak_flow_utils"
|
8
|
+
models_path = "#{File.dirname(__FILE__)}/peak_flow_utils/models"
|
8
9
|
|
9
10
|
autoload :Notifier, "#{path}/notifier"
|
10
11
|
autoload :NotifierErrorParser, "#{path}/notifier_error_parser"
|
@@ -14,4 +15,12 @@ module PeakFlowUtils
|
|
14
15
|
autoload :NotifierSidekiq, "#{path}/notifier_sidekiq"
|
15
16
|
autoload :RspecHelper, "#{path}/rspec_helper"
|
16
17
|
autoload :HandlerHelper, "#{path}/handler_helper"
|
18
|
+
|
19
|
+
autoload :ApplicationRecord, "#{models_path}/application_record"
|
20
|
+
autoload :Group, "#{models_path}/group"
|
21
|
+
autoload :HandlerText, "#{models_path}/handler_text"
|
22
|
+
autoload :Handler, "#{models_path}/handler"
|
23
|
+
autoload :ScannedFile, "#{models_path}/scanned_file"
|
24
|
+
autoload :TranslationKey, "#{models_path}/translation_key"
|
25
|
+
autoload :TranslationValue, "#{models_path}/translation_value"
|
17
26
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class PeakFlowUtils::Notifier
|
2
|
+
class FailedToReportError < RuntimeError; end
|
2
3
|
class NotConfiguredError < RuntimeError; end
|
3
4
|
|
4
5
|
attr_reader :auth_token
|
@@ -8,7 +9,7 @@ class PeakFlowUtils::Notifier
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.current
|
11
|
-
raise PeakFlowUtils::Notifier::NotConfiguredError, "Hasn't been configured"
|
12
|
+
raise PeakFlowUtils::Notifier::NotConfiguredError, "Hasn't been configured" if !@current && Rails.env.test?
|
12
13
|
|
13
14
|
@current
|
14
15
|
end
|
@@ -54,8 +55,29 @@ class PeakFlowUtils::Notifier
|
|
54
55
|
request.body = JSON.generate(data)
|
55
56
|
|
56
57
|
response = https.request(request)
|
58
|
+
|
59
|
+
raise FailedToReportError, error_message_from_response(response) unless response.code == "200"
|
60
|
+
|
57
61
|
response_data = JSON.parse(response.body)
|
58
62
|
|
59
|
-
|
63
|
+
# Data not always present so dont use fetch
|
64
|
+
PeakFlowUtils::NotifierResponse.new(
|
65
|
+
bug_report_id: response_data["bug_report_id"],
|
66
|
+
bug_report_instance_id: response_data["bug_report_instance_id"],
|
67
|
+
project_id: response_data["project_id"],
|
68
|
+
project_slug: response_data["project_slug"],
|
69
|
+
url: response_data["url"]
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def error_message_from_response(response)
|
74
|
+
message = "Couldn't report error to Peakflow (code #{response.code})"
|
75
|
+
|
76
|
+
if response["content-type"]&.starts_with?("application/json")
|
77
|
+
response_data = JSON.parse(response.body)
|
78
|
+
message << ": #{response_data.fetch("errors").join(". ")}" if response_data["errors"]
|
79
|
+
end
|
80
|
+
|
81
|
+
message
|
60
82
|
end
|
61
83
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
class PeakFlowUtils::NotifierResponse
|
2
|
-
attr_reader :url
|
2
|
+
attr_reader :bug_report_id, :bug_report_instance_id, :project_id, :project_slug, :url
|
3
3
|
|
4
|
-
def initialize(url:)
|
4
|
+
def initialize(bug_report_id:, bug_report_instance_id:, project_id:, project_slug:, url:)
|
5
|
+
@bug_report_id = bug_report_id
|
6
|
+
@bug_report_instance_id = bug_report_instance_id
|
7
|
+
@project_id = project_id
|
8
|
+
@project_slug = project_slug
|
5
9
|
@url = url
|
6
10
|
end
|
7
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peak_flow_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -119,11 +119,9 @@ files:
|
|
119
119
|
- MIT-LICENSE
|
120
120
|
- README.md
|
121
121
|
- Rakefile
|
122
|
-
- app/assets/config/peak_flow_utils_manifest.js
|
123
|
-
- app/assets/javascripts/peak_flow_utils/application.js
|
124
|
-
- app/assets/stylesheets/peak_flow_utils/application.css
|
125
122
|
- app/controllers/peak_flow_utils/application_controller.rb
|
126
|
-
- app/controllers/peak_flow_utils/pings/
|
123
|
+
- app/controllers/peak_flow_utils/pings/postgres_connections_controller.rb
|
124
|
+
- app/controllers/peak_flow_utils/pings/sidekiq_controller.rb
|
127
125
|
- app/handlers/peak_flow_utils/application_handler.rb
|
128
126
|
- app/handlers/peak_flow_utils/devise_handler.rb
|
129
127
|
- app/handlers/peak_flow_utils/file_handler.rb
|
@@ -132,16 +130,6 @@ files:
|
|
132
130
|
- app/handlers/peak_flow_utils/simple_form_handler.rb
|
133
131
|
- app/handlers/peak_flow_utils/validations_handler.rb
|
134
132
|
- app/handlers/peak_flow_utils/will_paginate_handler.rb
|
135
|
-
- app/helpers/peak_flow_utils/application_helper.rb
|
136
|
-
- app/jobs/peak_flow_utils/application_job.rb
|
137
|
-
- app/mailers/peak_flow_utils/application_mailer.rb
|
138
|
-
- app/models/peak_flow_utils/application_record.rb
|
139
|
-
- app/models/peak_flow_utils/group.rb
|
140
|
-
- app/models/peak_flow_utils/handler.rb
|
141
|
-
- app/models/peak_flow_utils/handler_text.rb
|
142
|
-
- app/models/peak_flow_utils/scanned_file.rb
|
143
|
-
- app/models/peak_flow_utils/translation_key.rb
|
144
|
-
- app/models/peak_flow_utils/translation_value.rb
|
145
133
|
- app/services/peak_flow_utils/application_migration.rb
|
146
134
|
- app/services/peak_flow_utils/application_service.rb
|
147
135
|
- app/services/peak_flow_utils/attribute_service.rb
|
@@ -155,7 +143,6 @@ files:
|
|
155
143
|
- app/services/peak_flow_utils/model_inspector.rb
|
156
144
|
- app/services/peak_flow_utils/translation_service.rb
|
157
145
|
- app/services/peak_flow_utils/translations_parser_service.rb
|
158
|
-
- app/views/layouts/peak_flow_utils/application.html.erb
|
159
146
|
- bin/peak_flow_rspec_files
|
160
147
|
- config/routes.rb
|
161
148
|
- lib/peak_flow_utils.rb
|
@@ -167,6 +154,13 @@ files:
|
|
167
154
|
- lib/peak_flow_utils/migrations/20150908085500_create_translation_values.rb
|
168
155
|
- lib/peak_flow_utils/migrations/20150908090800_create_handler_texts.rb
|
169
156
|
- lib/peak_flow_utils/migrations/20160411190500_create_scanned_files.rb
|
157
|
+
- lib/peak_flow_utils/models/application_record.rb
|
158
|
+
- lib/peak_flow_utils/models/group.rb
|
159
|
+
- lib/peak_flow_utils/models/handler.rb
|
160
|
+
- lib/peak_flow_utils/models/handler_text.rb
|
161
|
+
- lib/peak_flow_utils/models/scanned_file.rb
|
162
|
+
- lib/peak_flow_utils/models/translation_key.rb
|
163
|
+
- lib/peak_flow_utils/models/translation_value.rb
|
170
164
|
- lib/peak_flow_utils/notifier.rb
|
171
165
|
- lib/peak_flow_utils/notifier_error_parser.rb
|
172
166
|
- lib/peak_flow_utils/notifier_rack.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require activestorage
|
14
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
-
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
-
* It is generally better to create a new file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Peak flow utils</title>
|
5
|
-
<%= stylesheet_link_tag "peak_flow_utils/application", media: "all" %>
|
6
|
-
<%= javascript_include_tag "peak_flow_utils/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|