-
Notifications
You must be signed in to change notification settings - Fork 103
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
Optimization 3 #103
base: master
Are you sure you want to change the base?
Optimization 3 #103
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.
Всё супер 👍👍
- `rails s` | ||
- `open http://localhost:3000/автобусы/Самара/Москва` | ||
- `make open` |
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.
👍
@@ -2,6 +2,6 @@ class TripsController < ApplicationController | |||
def index | |||
@from = City.find_by_name!(params[:from]) | |||
@to = City.find_by_name!(params[:to]) | |||
@trips = Trip.where(from: @from, to: @to).order(:start_time) | |||
@trips = Trip.preload(bus: :services).where(from: @from, to: @to).order(:start_time).load |
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.
👍
trip['bus']['services'].map do |service| | ||
services[service] ||= Service.new(name: service) | ||
end | ||
end |
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.
Идеально
|
||
Перенес код по импорту данных из rake task в отдельный интерактор `ImportData` | ||
|
||
Для того, чтобы лучше разобраться в коде и защитить его, написал rspec тесты и сделал рефакторинг |
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.
👍
#### 5. | ||
|
||
Вернул обратно partials, но сделал их вызов с указанием коллекции | ||
Это сделало код более читабельным, но при этом мы не потеряли в производительности |
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.
Полностью согласен, почти всем на ревью пишу этот варик
| |ДО |ПОСЛЕ ПЕРВОГО ШАГА |ПОСЛЕ ОБНОВЛЕНИЯ RUBY | | ||
|------------------|--------------------------|--------------------------|----------------------| | ||
| example.json | 0.547757 сек | 0.257931 сек | 0.221117 сек | | ||
| large.json | очень долго | 56 сек | 45.511732 сек | |
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.
Найс, чуть ли не 20% буст
No description provided.