Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[potashin] optimization 4 #139

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.3
2.7.8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сори за неудобство

9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rubocop:disable LineLength
source "https://rubygems.org"
ruby "2.6.3"
ruby "2.7.8"

# Enforce git to transmitted via https.
# workaround until bundler 2.0 is released.
Expand Down Expand Up @@ -102,6 +102,12 @@ gem "uglifier", "~> 4.1"
gem "validate_url", "~> 1.0"
gem "webpacker", "~> 3.5"
gem "webpush", "~> 0.3"
gem 'newrelic_rpm'
gem 'rack-mini-profiler', require: false
gem 'yabeda-prometheus'
gem 'yabeda-rails'
gem 'yabeda-puma-plugin'
gem 'influxdb-rails'

group :development do
gem "better_errors", "~> 2.5"
Expand All @@ -115,6 +121,7 @@ group :development do
gem "guard-rspec", "~> 4.7", require: false
gem "rb-fsevent", "~> 0.10", require: false
gem "web-console", "~> 3.7"
# gem 'meta_request'
end

group :development, :test do
Expand Down
87 changes: 63 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ GEM
json (~> 1.8)
ancestry (3.0.5)
activerecord (>= 3.2.0)
anyway_config (2.6.4)
ruby-next-core (~> 1.0)
approvals (0.0.24)
nokogiri (~> 1.6)
thor (~> 0.18)
Expand Down Expand Up @@ -151,7 +153,7 @@ GEM
html_tokenizer (~> 0.0.6)
parser (>= 2.4)
smart_properties
bindex (0.5.0)
bindex (0.8.1)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bourbon (5.1.0)
Expand All @@ -168,14 +170,14 @@ GEM
rake
yajl-ruby
buftok (0.2.0)
builder (3.2.3)
builder (3.2.4)
bullet (5.9.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
bundler-audit (0.6.0)
bundler (~> 1.2)
thor (~> 0.18)
byebug (11.0.0)
byebug (11.1.3)
capybara (3.13.2)
addressable
mini_mime (>= 0.1.3)
Expand Down Expand Up @@ -212,15 +214,15 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
concurrent-ruby (1.2.3)
connection_pool (2.2.2)
counter_culture (2.1.2)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
after_commit_action (~> 1.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4)
crass (1.0.6)
csv_shaper (1.3.0)
activesupport (>= 3.0.0)
dalli (2.7.9)
Expand Down Expand Up @@ -269,6 +271,7 @@ GEM
activemodel-serializers-xml (~> 1.0)
activesupport (~> 5.0)
request_store (~> 1.0)
dry-initializer (3.1.1)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
Expand All @@ -288,7 +291,7 @@ GEM
rubocop (~> 0.51)
smart_properties
errbase (0.1.0)
erubi (1.8.0)
erubi (1.12.0)
et-orbi (1.1.6)
tzinfo
eventmachine (1.2.5)
Expand Down Expand Up @@ -536,10 +539,14 @@ GEM
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.6.0)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
inflecto (0.0.2)
influxdb (0.8.1)
influxdb-rails (1.0.3)
influxdb (~> 0.6, >= 0.6.4)
railties (>= 5.0)
inline_svg (1.3.1)
activesupport (>= 3.0)
nokogiri (>= 1.6)
Expand Down Expand Up @@ -582,9 +589,9 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.2.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
nokogiri (>= 1.12.0)
lumberjack (1.0.13)
mail (2.7.1)
mini_mime (>= 0.1.1)
Expand All @@ -597,8 +604,8 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
mini_portile2 (2.8.6)
minitest (5.23.1)
momentjs-rails (2.20.1)
railties (>= 3.1)
msgpack (1.2.4)
Expand All @@ -612,9 +619,11 @@ GEM
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
netrc (0.11.0)
newrelic_rpm (9.9.0)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
nokogiri (1.15.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
Expand Down Expand Up @@ -651,10 +660,11 @@ GEM
ast (~> 2.4.0)
pg (1.1.4)
powerpack (0.1.2)
prometheus-client (4.2.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.7.0)
pry-byebug (3.8.0)
byebug (~> 11.0)
pry (~> 0.10)
pry-rails (0.3.9)
Expand All @@ -674,15 +684,18 @@ GEM
rest-client
pusher-signature (0.1.8)
raabro (1.1.6)
rack (2.0.6)
racc (1.8.0)
rack (2.2.9)
rack-host-redirect (1.3.0)
rack
rack-mini-profiler (3.3.1)
rack (>= 1.2.0)
rack-protection (2.0.4)
rack
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack-test (2.1.0)
rack (>= 1.3)
rack-timeout (0.5.1)
rails (5.1.6.2)
actioncable (= 5.1.6.2)
Expand All @@ -701,11 +714,13 @@ GEM
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-observers (0.1.5)
activemodel (>= 4.0)
railties (5.1.6.2)
Expand All @@ -715,7 +730,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
rake (12.3.2)
rake (12.3.3)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand Down Expand Up @@ -781,6 +796,7 @@ GEM
unicode-display_width (~> 1.4.0)
rubocop-rspec (1.31.0)
rubocop (>= 0.60.0)
ruby-next-core (1.0.3)
ruby-prof (0.17.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
Expand Down Expand Up @@ -895,7 +911,7 @@ GEM
multipart-post (~> 2.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
tzinfo (1.2.5)
tzinfo (1.2.11)
thread_safe (~> 0.1)
uber (0.1.0)
uglifier (4.1.20)
Expand Down Expand Up @@ -938,6 +954,23 @@ GEM
xml-simple (1.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yabeda (0.12.0)
anyway_config (>= 1.0, < 3)
concurrent-ruby
dry-initializer
yabeda-prometheus (0.9.1)
prometheus-client (>= 3.0, < 5.0)
rack
yabeda (~> 0.10)
yabeda-puma-plugin (0.7.1)
json
puma
yabeda (~> 0.5)
yabeda-rails (0.9.0)
activesupport
anyway_config (>= 1.3, < 3)
railties
yabeda (~> 0.8)
yajl-ruby (1.4.1)
zonebie (0.6.1)

Expand Down Expand Up @@ -1004,6 +1037,7 @@ DEPENDENCIES
honeycomb-rails
html_truncator (~> 0.4)
httparty (~> 0.16)
influxdb-rails
inline_svg (~> 1.3)
jbuilder (~> 2.8)
jquery-rails (~> 4.3)
Expand All @@ -1013,6 +1047,7 @@ DEPENDENCIES
liquid (~> 4.0)
memory_profiler (~> 0.9)
nakayoshi_fork
newrelic_rpm
nokogiri (~> 1.10)
octokit (~> 4.13)
omniauth (~> 1.9)
Expand All @@ -1029,6 +1064,7 @@ DEPENDENCIES
pusher (~> 1.3)
pusher-push-notifications (~> 1.0)
rack-host-redirect (~> 1.3)
rack-mini-profiler
rack-timeout (~> 0.5)
rails (~> 5.1.6)
rails-assets-airbrake-js-client (~> 1.5)!
Expand Down Expand Up @@ -1079,10 +1115,13 @@ DEPENDENCIES
webmock (~> 3.5)
webpacker (~> 3.5)
webpush (~> 0.3)
yabeda-prometheus
yabeda-puma-plugin
yabeda-rails
zonebie (~> 0.6.1)

RUBY VERSION
ruby 2.6.3p62
ruby 2.7.8p225

BUNDLED WITH
1.17.3
16 changes: 16 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class ApplicationController < ActionController::Base
include Pundit
include Instrumentation

before_action :authorize_rmp, if: :authorize_rmp?

def require_http_auth
authenticate_or_request_with_http_basic do |username, password|
username == ApplicationConfig["APP_NAME"] && password == ApplicationConfig["APP_PASSWORD"]
Expand Down Expand Up @@ -78,4 +80,18 @@ def append_info_to_payload(payload)
super(payload)
append_to_honeycomb(request, self.class.name)
end

def authorize_rmp
Rack::MiniProfiler.authorize_request
end

def authorize_rmp?
return true unless Rails.env.production?

if current_user
current_user.admin?
else
ENV['RMP_TOKEN'] == params[:rmp_token]
end
end
end
14 changes: 8 additions & 6 deletions app/views/stories/_main_stories_feed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
</div>
<% end %>
<% else %>
<% @stories.each_with_index do |story, i| %>
<% next if story.id == @featured_story.id %>
<% if !user_signed_in? && i == 4 %>
<%= render "stories/sign_in_invitation" %>
<% @stories.each_with_index do |story, i| %>
<% next if story.id == @featured_story.id %>
<% if !user_signed_in? && i == 4 %>
<%= render "stories/sign_in_invitation" %>
<% end %>
<% cache(story) do %>
<%= render "articles/single_story", story: story %>
<% end %>
<% end %>
<%= render "articles/single_story", story: story %>
<% end %>
<% end %>
<% if @stories.size > 1 %>
<div class="placeholder-div"></div>
Expand Down
2 changes: 1 addition & 1 deletion bin/webpack-dev-server
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def args(key)
end

begin
dev_server = YAML.load_file(CONFIG_FILE)[RAILS_ENV]["dev_server"]
dev_server = YAML.load_file(CONFIG_FILE, aliases: true)[RAILS_ENV]["dev_server"]

HOSTNAME = args("--host") || dev_server["host"]
PORT = args("--port") || dev_server["port"]
Expand Down
Loading