From 68c3d035b3f165501b41085272d462358161f063 Mon Sep 17 00:00:00 2001 From: SomewhatDamaged Date: Wed, 25 Dec 2019 19:49:56 +1100 Subject: [PATCH] Update to streamline Wilson score generation (#10) * Update to streamline Wilson score generation If an image's `upvotes` are 0, their Wilson score will be so minuscule as to be several (around 12) orders of magnitude before you see anything but zeros (assuming 0 `upvotes` and 1 `downvotes`). This will simply remove the calculation from such and make them fall to the default: 0 * Update elasticsearch_index.ex Co-authored-by: liamwhite --- lib/philomena/images/elasticsearch_index.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/philomena/images/elasticsearch_index.ex b/lib/philomena/images/elasticsearch_index.ex index 44be16e8..831546f9 100644 --- a/lib/philomena/images/elasticsearch_index.ex +++ b/lib/philomena/images/elasticsearch_index.ex @@ -143,8 +143,7 @@ defmodule Philomena.Images.ElasticsearchIndex do } end - def wilson_score(%{upvotes_count: upvotes, downvotes_count: downvotes}) - when upvotes > 0 or downvotes > 0 do + def wilson_score(%{upvotes_count: upvotes, downvotes_count: downvotes}) when upvotes > 0 do # Population size n = (upvotes + downvotes) / 1