Improving the Dropbox sync #2

:  ~ 25 sec read

I remembered I have a Hazel rule that syncs the files automatically when a new file is added. So I realised I can improve the future posts even further: instead of excluding files, it's better to exclude posts, based on date:

get '/' do
  [...]
  all_posts.reject! do |post|
    time_from_string(post[:datetime]) == nil || DateTime.now.to_time < time_from_string(post[:datetime])
  end
  [...]
end

get '/feed' do
  [...]
  posts.each do |post|
    next if time_from_string(post[:datetime]) == nil || DateTime.now.to_time < time_from_string(post[:datetime])
    [...]
    end
  [...]
end