FIX: Histories should be reverse chronological

FIX: Histories should be reverse chronological

diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb
index 7c43284..00a9eb9 100644
--- a/app/models/reviewable.rb
+++ b/app/models/reviewable.rb
@@ -30,7 +30,7 @@ class Reviewable < ActiveRecord::Base
   belongs_to :category
 
   has_many :reviewable_histories
-  has_many :reviewable_scores
+  has_many :reviewable_scores, -> { order(created_at: :desc) }
 
   after_create do
     log_history(:created, created_by)

GitHub sha: a2598632

Should Histories or Scores be in reverse chronological order?

I don’t understand the question - that’s what the change does? The scores are now in reverse chronological order.

The commit message says “Histories should be reverse chronological” and you changed the order on reviewable_scores instead of reviewable_histories?

Oh I understand. When viewing the reviewable in the UX, the scores are effectively the “history”. The commit message is confusing because there is also a histories table which is an audit log of actions taken on the reviewable.

The commit is correct, the message is not.

2 Likes