-
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
Task #3 [Oleynik] #35
base: master
Are you sure you want to change the base?
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.
👍
</h2> | ||
|
||
<% @trips.each do |trip| %> | ||
<ul> | ||
<%= render "trip", trip: trip %> | ||
<li><%= "Отправление: #{trip.start_time}" %></li> |
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.
Так быстрее, но с другой стороны вроде бы почище смотрится этот partial в отдельном файле
Можно было бы попробовать оставить partial, но рендерить не в цикле, а коллекцией
|
||
config.after_initialize do | ||
Bullet.enable = true | ||
Bullet.add_footer = true |
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,4 +2,6 @@ | |||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |||
get "/" => "statistics#index" | |||
get "автобусы/:from/:to" => "trips#index" | |||
|
|||
mount PgHero::Engine, at: "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.
👍
t.integer "service_id" | ||
t.string "bus_id" | ||
t.string "service_id" | ||
t.index ["bus_id", "service_id"], name: "index_buses_services_on_bus_id_and_service_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.
👍 плюсик за составной индекс
t.string "start_time" | ||
t.integer "duration_minutes" | ||
t.integer "price_cents" | ||
t.integer "bus_id" | ||
t.index ["from_id", "to_id"], name: "index_trips_on_from_id_and_to_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.
👍
@@ -34,12 +37,13 @@ | |||
end | |||
|
|||
create_table "trips", force: :cascade do |t| | |||
t.integer "from_id" | |||
t.integer "to_id" | |||
t.string "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.
А зачем на строку поменяли?
@@ -1,34 +1,68 @@ | |||
# Наивная загрузка данных из json-файла в БД | |||
# frozen_string_literal: true |
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-таски в ruby-класс
Rake::Task.define_task(:environment) | ||
end | ||
|
||
it 'выполняется без ошибок' do |
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 | ||
- PGHero показал точку роста при запросе маршрутов. | ||
- Добавил индекс на атрибуты по которому производится поиск `[:from_id, :to_id]` в таблицу `trips`. | ||
- Эта точка роста не находилась выше всех и осталась на своем месте, но время обращения к базе снизилось - до *50ms*. |
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.
Всячески поддерживаю облегчение жизни БД с помощью ускорения запросов и плюсик за составной индекс 👍
Но тут видно, что на общем фоне рендеринга страницы за 3000ms прирост в 15ms погоды не делает
No description provided.