Fix bad rating calculation
This commit is contained in:
@@ -219,6 +219,7 @@ class ITunesParser:
|
||||
file_artist = io.open('es-artist-data.json', 'wb')
|
||||
for artist in self._artists:
|
||||
persistent_id = self._artists[artist]['Persistent ID']
|
||||
self._artists[artist]['Rating'] = round(self._artists[artist]['Rating'])
|
||||
json_track_index = {
|
||||
"index": {"_index": "itunessongs", "_type": "artist", "_id": persistent_id}
|
||||
}
|
||||
@@ -236,6 +237,7 @@ class ITunesParser:
|
||||
file_albums = io.open('es-albums-data.json', 'wb')
|
||||
for album in self._albums:
|
||||
persistent_id = self._albums[album]['Persistent ID']
|
||||
self._albums[album]['Rating'] = round(self._albums[album]['Rating'])
|
||||
json_track_index = {
|
||||
"index": {"_index": "itunessongs", "_type": "album", "_id": persistent_id}
|
||||
}
|
||||
@@ -250,7 +252,7 @@ class ITunesParser:
|
||||
"""
|
||||
Calculate average rating from a current rating, a rating value to add and the number of elements
|
||||
"""
|
||||
return (current_rating * count + added_value) // (count + 1)
|
||||
return (current_rating * count + added_value) / (count + 1)
|
||||
|
||||
@classmethod
|
||||
def calc_id(cls, key):
|
||||
|
||||
Reference in New Issue
Block a user