mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-04 06:31:57 +00:00 
			
		
		
		
	Fix average rating where likes and dislikes are null
This commit is contained in:
		@@ -649,7 +649,9 @@ def fetch_video(id, proxies, region)
 | 
			
		||||
  dislikes = dislikes.try &.content.delete(",").try &.to_i?
 | 
			
		||||
  dislikes ||= 0
 | 
			
		||||
 | 
			
		||||
  info["avg_rating"] = "#{(likes.to_f/(likes.to_f + dislikes.to_f) * 4 + 1)}"
 | 
			
		||||
  avg_rating = (likes.to_f/(likes.to_f + dislikes.to_f) * 4 + 1)
 | 
			
		||||
  avg_rating = avg_rating.nan? ? 0.0 : avg_rating
 | 
			
		||||
  info["avg_rating"] = "#{avg_rating}"
 | 
			
		||||
 | 
			
		||||
  description = html.xpath_node(%q(//p[@id="eow-description"]))
 | 
			
		||||
  description = description ? description.to_xml : ""
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user