Clearer syntax in migration

Clearer syntax in migration

Following up on 1c1fd205

diff --git a/db/migrate/20190110142917_enable_content_security_policy_for_new_sites.rb b/db/migrate/20190110142917_enable_content_security_policy_for_new_sites.rb
index bf7af9f..abe5535 100644
--- a/db/migrate/20190110142917_enable_content_security_policy_for_new_sites.rb
+++ b/db/migrate/20190110142917_enable_content_security_policy_for_new_sites.rb
@@ -18,8 +18,8 @@ class EnableContentSecurityPolicyForNewSites < ActiveRecord::Migration[5.2]
   end
 
   def instance_is_new?
-    post = DB.query_single("SELECT created_at FROM posts ORDER BY created_at ASC LIMIT 1")
-    return post.blank? || (post.present? && post.first > 1.week.ago)
+    dates = DB.query_single("SELECT created_at FROM posts ORDER BY created_at ASC LIMIT 1")
+    dates.empty? || dates.first > 1.week.ago
   end
 
 end

GitHub sha: fb7f21fb

2 Likes