mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Fix engagement for zero-view videos (#654)
Division by zero resulted in 'NaN'. Fixes https://github.com/omarroth/invidious/issues/653.
This commit is contained in:
parent
ec36c69984
commit
f99a7b2a8c
1 changed files with 5 additions and 1 deletions
|
@ -521,7 +521,11 @@ get "/watch" do |env|
|
|||
end
|
||||
|
||||
rating = video.info["avg_rating"].to_f64
|
||||
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
|
||||
if video.views > 0
|
||||
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
|
||||
else
|
||||
engagement = 0
|
||||
end
|
||||
|
||||
playability_status = video.player_response["playabilityStatus"]?
|
||||
if playability_status && playability_status["status"] == "LIVE_STREAM_OFFLINE" && !video.premiere_timestamp
|
||||
|
|
Loading…
Reference in a new issue