-
Notifications
You must be signed in to change notification settings - Fork 115
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
Valeev dz3 #21
base: master
Are you sure you want to change the base?
Valeev dz3 #21
Conversation
ruvaleev
commented
Feb 23, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve, можно было бы ещё индексов добавить для ускорения выборок
@@ -7,6 +7,15 @@ gem 'rails', '~> 5.2.3' | |||
gem 'pg', '>= 0.18', '< 2.0' | |||
gem 'puma', '~> 3.11' | |||
gem 'bootsnap', '>= 1.1.0', require: false | |||
gem 'newrelic_rpm' | |||
gem 'pghero' | |||
gem 'badger-rails' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ого
@@ -0,0 +1,84 @@ | |||
class ReloadJson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошо, что вынесли в отдельный сервис, но название непонятное
@@ -0,0 +1,84 @@ | |||
class ReloadJson | |||
def call(file_name, without_db_queries = false) | |||
json = JSON.parse(File.read(file_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Грузим потенциально большой JSON сразу весь в память -> bloat
@@ -2,15 +2,24 @@ | |||
<%= "Автобусы #{@from.name} – #{@to.name}" %> | |||
</h1> | |||
<h2> | |||
<%= "В расписании #{@trips.count} рейсов" %> | |||
<%= "В расписании #{@trips.load.size} рейсов" %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 Вы первый, кто сделал load.size
, хотя именно так и было в лекции
После первой итерации (только Trips завернули в import) | ||
Finish in 116.12 | ||
|
||
### Защитимся от внесения функциональных ошибок тестом test/services/reload_json_spec.rb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
Вдобавок ко всему, сделаем это, отказавщись от хэшей, используя только массивы (за исключением json-а) | ||
|
||
Результат оказался очень впечатляющим. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
### Седьмая гипотеза | ||
#### Убрать все вычисления во вьюхе trips/index.html.erb | ||
|
||
Никакого профита, первый раз страница загрузилась даже за 9+ секунд. Так что геморрой с костылями и колбэками себя не оправдывает. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошо, что решили оценить перед тем как делать!