-
Notifications
You must be signed in to change notification settings - Fork 114
Optimization trips import and render #108
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| DB_HOST=db | ||
| DB_USER=postgres | ||
| DB_PASSWORD=1q2w3e4r | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ | |
| /tmp | ||
| /log | ||
| /public | ||
| .env | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| FROM ruby:2.6.3 | ||
|
|
||
| RUN gem install bundler:2.0.2 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY Gemfile Gemfile.lock ./ | ||
|
|
||
| RUN bundle install | ||
|
|
||
| COPY . . | ||
|
|
||
| CMD ["rails", "server", "-b", "0.0.0.0"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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.where(from: @from, to: @to).order(:start_time).preload(bus: :services).load | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| class BusesService < ApplicationRecord | ||
| belongs_to :bus | ||
| belongs_to :service | ||
| end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,15 +2,24 @@ | |
| <%= "Автобусы #{@from.name} – #{@to.name}" %> | ||
| </h1> | ||
| <h2> | ||
| <%= "В расписании #{@trips.count} рейсов" %> | ||
| <%= "В расписании #{@trips.size} рейсов" %> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| <li><%= "Прибытие: #{(Time.parse(trip.start_time) + trip.duration_minutes.minutes).strftime('%H:%M')}" %></li> | ||
| <li><%= "В пути: #{trip.duration_minutes / 60}ч. #{trip.duration_minutes % 60}мин." %></li> | ||
| <li><%= "Цена: #{trip.price_cents / 100}р. #{trip.price_cents % 100}коп." %></li> | ||
| <li><%= "Автобус: #{trip.bus.model} №#{trip.bus.number}" %></li> | ||
| <% if trip.bus.services.present? %> | ||
| <%= render "services", services: trip.bus.services %> | ||
| <li>Сервисы в автобусе:</li> | ||
| <ul> | ||
| <% trip.bus.services.each do |service| %> | ||
| <li><%= "#{service.name}" %></li> | ||
| <% end %> | ||
| </ul> | ||
| <% end %> | ||
| </ul> | ||
| <%= render "delimiter" %> | ||
| ==================================================== | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: есть API для рендеринга коллекций, там можно даже указать шаблон spacer параметром. |
||
| <% 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.
😬😬😬
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.
Это файл с примером необходимых переменных окружения, значения из него не грузятся))