-
Notifications
You must be signed in to change notification settings - Fork 104
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
Task3 homework #84
base: master
Are you sure you want to change the base?
Task3 homework #84
Conversation
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.
✅
@@ -1 +1 @@ | |||
2.6.3 | |||
3.1.2 |
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.
👍👍
gem 'net-smtp' | ||
gem 'pg', '>= 0.18', '< 2.0' | ||
gem 'puma', '~> 5.6' | ||
gem 'rails', '~> 7.0' |
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.
👍👍
</ul> | ||
<%= render "delimiter" %> | ||
<% end %> | ||
<%= render partial: "trip", collection: @trips, spacer_template: "delimiter" %> |
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.
моё почтение 👍
|
||
## Оптимизация отображения данных на странице | ||
После импорта файлов был произведен анализ с помощью `PgHero` | ||
Как и ожидалось, в таблицы необходимо было добавить индексы. После их добавления `PgHero` полностью позеленел. |
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.
✅
|
||
При первом запуске `RailsPanel` показал огромное количество рендеринга паршиалов для каждой записи. Это и предстоит оптимизировать. | ||
|
||
После уменьшения количества паршиалов с помощью рендера коллекции и передачи разделителя как параметра `spacer_template` рендеринг страницы с автобусами `Самара - Москва` стал занимать чуть более 1 секунды. |
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.
⚡️
task :reload_json, [:file_name] => :environment do |_task, args| | ||
json = JSON.parse(File.read(args.file_name)) | ||
uniq_cities = json.pluck('from', 'to').flatten.uniq.map! { |name| { name: 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.
лучше выносить такую логику в отдельный класс, так удобнее работать
rake-таска только для приёма аргументов и запуска класса
end | ||
bus = Bus.find_or_create_by(number: trip['bus']['number']) | ||
bus.update(model: trip['bus']['model'], services: services) | ||
from_id = cities.to_a.detect { |city| city['name'] == trip['from'] }['id'] |
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.
вот это что-то оочень сомнительное решение
в цикле на каждой итерации создаём новый массив cities - плохо
ищем по массиву с помощью detect - тоже плохо, это же сложность O(N). А если мы соберём города в hash, то будем находить по ключу за O(1)
No description provided.