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

Task3 homework #84

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

Task3 homework #84

wants to merge 12 commits into from

Conversation

vsav
Copy link

@vsav vsav commented Jun 6, 2022

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.

@@ -1 +1 @@
2.6.3
3.1.2
Copy link
Collaborator

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

моё почтение 👍


## Оптимизация отображения данных на странице
После импорта файлов был произведен анализ с помощью `PgHero`
Как и ожидалось, в таблицы необходимо было добавить индексы. После их добавления `PgHero` полностью позеленел.
Copy link
Collaborator

Choose a reason for hiding this comment

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


При первом запуске `RailsPanel` показал огромное количество рендеринга паршиалов для каждой записи. Это и предстоит оптимизировать.

После уменьшения количества паршиалов с помощью рендера коллекции и передачи разделителя как параметра `spacer_template` рендеринг страницы с автобусами `Самара - Москва` стал занимать чуть более 1 секунды.
Copy link
Collaborator

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

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

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)

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