Skip to content

optimizations#14

Open
yarafan wants to merge 2 commits intospajic:masterfrom
yarafan:master
Open

optimizations#14
yarafan wants to merge 2 commits intospajic:masterfrom
yarafan:master

Conversation

@yarafan
Copy link

@yarafan yarafan commented May 16, 2019

No description provided.

Copy link
Owner

@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.

Хорошая, интересная работа!
Попробуйте теперь bonus-task-2 в развитие этой темы

end

def import_cities
cities = Set.new
Copy link
Owner

Choose a reason for hiding this comment

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

Интересная идея с Set!
По-моему первый раз встречается среди домашних работ этого задания.

@@ -1,16 +1,7 @@
<h1>
<%= "Автобусы #{@from.name} – #{@to.name}" %>
<%= "Автобусы #{params[:from]} – #{params[:to]}" %>
Copy link
Owner

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", cached: true %>
Copy link
Owner

Choose a reason for hiding this comment

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

👍 Плюсик за spacer_template!


### Загрузка данных в базу
## Находка №1
Для обработки каждой json записи инициализируется несколько объектов и каждый из них в отдельной транзакции вставляется в базу данных, что крайне неэффективно на больших объемах. Было принято решение использовать ```gem activerecord-import```, для массовой вставки данных
Copy link
Owner

Choose a reason for hiding this comment

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

👍

Для обработки каждой json записи инициализируется несколько объектов и каждый из них в отдельной транзакции вставляется в базу данных, что крайне неэффективно на больших объемах. Было принято решение использовать ```gem activerecord-import```, для массовой вставки данных

## Находка №2
Используется устаревший метод ```has_and_belongs_to_many```. Использовав связную модель через ```has many through:```, появляется возможность более эффективно использовать ```gem activerecord import```
Copy link
Owner

Choose a reason for hiding this comment

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

👍

Используется устаревший метод ```has_and_belongs_to_many```. Использовав связную модель через ```has many through:```, появляется возможность более эффективно использовать ```gem activerecord import```

## Находка №3
Используется не самая эффективная библиотека для работы с json. Было принято решение использовать ```gem oj```, для более эффективной обработки
Copy link
Owner

Choose a reason for hiding this comment

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

👍 Тут бы хорошо добавить инф-ю про эффект замены

disable_ddl_transaction!

def change
add_index :trips, [:from_id, :to_id], algorithm: :concurrently
Copy link
Owner

Choose a reason for hiding this comment

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

👍 плюсик за :concurrently

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