mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-03 21:58:29 -06:00 
			
		
		
		
	Fix engagement for zero-view videos
Division by zero resulted in 'NaN'. Fixes https://github.com/omarroth/invidious/issues/653.
This commit is contained in:
		
							parent
							
								
									8af33084ed
								
							
						
					
					
						commit
						c05f7de16f
					
				@ -521,7 +521,11 @@ get "/watch" do |env|
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  rating = video.info["avg_rating"].to_f64
 | 
					  rating = video.info["avg_rating"].to_f64
 | 
				
			||||||
 | 
					  if video.views > 0
 | 
				
			||||||
    engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
 | 
					    engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    engagement = 0
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  playability_status = video.player_response["playabilityStatus"]?
 | 
					  playability_status = video.player_response["playabilityStatus"]?
 | 
				
			||||||
  if playability_status && playability_status["status"] == "LIVE_STREAM_OFFLINE" && !video.premiere_timestamp
 | 
					  if playability_status && playability_status["status"] == "LIVE_STREAM_OFFLINE" && !video.premiere_timestamp
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user