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 <liamwhite@users.noreply.github.com>
This commit is contained in:
SomewhatDamaged 2019-12-25 19:49:56 +11:00 committed by liamwhite
parent dd84e8631b
commit 68c3d035b3

View file

@ -143,8 +143,7 @@ defmodule Philomena.Images.ElasticsearchIndex do
} }
end end
def wilson_score(%{upvotes_count: upvotes, downvotes_count: downvotes}) def wilson_score(%{upvotes_count: upvotes, downvotes_count: downvotes}) when upvotes > 0 do
when upvotes > 0 or downvotes > 0 do
# Population size # Population size
n = (upvotes + downvotes) / 1 n = (upvotes + downvotes) / 1