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

Optimization 3 #103

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Optimization 3 #103

wants to merge 13 commits into from

Conversation

MaksimPW
Copy link

No description provided.

Copy link
Collaborator

@spajic spajic left a 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`
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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' %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Идеально


Перенес код по импорту данных из rake task в отдельный интерактор `ImportData`

Для того, чтобы лучше разобраться в коде и защитить его, написал rspec тесты и сделал рефакторинг
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

#### 5.

Вернул обратно partials, но сделал их вызов с указанием коллекции
Это сделало код более читабельным, но при этом мы не потеряли в производительности
Copy link
Collaborator

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 сек |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Найс, чуть ли не 20% буст

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants