View Single Post
Old 03-16-2022, 01:45 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,465
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Almost certainly you got the wrong column. It is (in theory) impossible to put a value in a Rating column outside the range 0 .. 10. Furthermore, the value 2 will show 1 star and any value over 10 will show 5 stars.

The code that translates the number into stars is
Code:
def rating_to_stars(value, allow_half_stars=False, star='★', half='⯨'):
    r = max(0, min(int(value or 0), 10)) # value is limited to 0 .. 10
    ans = star * (r // 2) # generate (r int_divide by 2) stars.
    if allow_half_stars and r % 2: # if half stars and r mod 2 != 0, add it
        ans += half
    return ans
chaley is offline   Reply With Quote