Skip to content

Commit

Permalink
Reduce flights to 1 month for free database
Browse files Browse the repository at this point in the history
  • Loading branch information
rlmoser99 committed Mar 7, 2021
1 parent 6d76462 commit 08c2007
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/flights/_results_selection_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</div>

<% if @booking_options.empty? %>
<p>Sorry, no flights match your search criteria.</p>
<p>Sorry, no flights match your search criteria. Please choose a date within the next 30 days.</p>
<% else %>
<div class="form-button">
<%= f.submit "Book Flight" %>
Expand Down
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
Airport.find_or_create_by(code: "MCO", location: "Orlando, FL")
Airport.find_or_create_by(code: "DEN", location: "Denver, CO")

start = Time.zone.today - 31.days
finish = Time.zone.today + 62.days
start = Time.zone.today
finish = Time.zone.today + 31.days

(start..finish).each do |date|
flight_generator = FlightGenerator.new(date)
Expand Down
8 changes: 7 additions & 1 deletion lib/tasks/data_maintenance.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
namespace :data_maintenance do
desc "Generates flights to keep database current"
task generate_flights: :environment do
future_date = Time.zone.today + 62.days
future_date = Time.zone.today + 31.days
flight_generator = FlightGenerator.new(future_date)
flight_generator.call
end
desc "Destroy pasts flights to keep database managable"
task destroy_past_flights: :environment do
yesterday = Time.zone.today - 1.day
past_flights = Flight.where('departure_date < ?', yesterday)
past_flights.destroy_all
end
end

0 comments on commit 08c2007

Please sign in to comment.