Refactor rating bar

This commit is contained in:
Celestora 2021-10-09 22:42:20 +03:00
parent aa5ac03bb4
commit 5c9c09c7a9
3 changed files with 24 additions and 4 deletions

View file

@ -397,9 +397,15 @@ class User extends RowModel
$incompleteness += 20;
}
$total = max(100 - $incompleteness + $this->getRating(), 0);
if(quirk("profile.rating-bar-behaviour") === 0)
$percent = intval(substr(strval($total), -2));
else
$percent = min($total, 100);
return (object) [
"total" => 100 - $incompleteness + $this->getRating(),
"percent" => min(100 - $incompleteness + $this->getRating(), 100),
"total" => $total,
"percent" => $percent,
"unfilled" => $unfilled,
];
}

View file

@ -122,8 +122,8 @@
<div n:if="isset($thisUser) && !$thisUser->prefersNotToSeeRating()" class="profile-hints">
{var completeness = $user->getProfileCompletenessReport()}
<div class="completeness-gauge, $completeness->total >= 100 ? completeness-gauge-gold">
<div style="width: {if ($completeness->total >= 100)}{round(($completeness->total / 10**strlen(strval($completeness->total))) * 100, 0)}{else}{$completeness->percent}{/if}%"></div>
<div n:class="completeness-gauge, $completeness->total >= 100 ? completeness-gauge-gold">
<div style="width: {$completeness->percent}%"></div>
<span>{$completeness->total}%</span>
</div>

View file

@ -0,0 +1,14 @@
# Rating bar behaviour
# If rating overflows 100 older versions of OpenVK
# used to render a full bar, but original VK used to
# treat last two digits of rating as % of bar fullness.
#
# Example:
# Rating 20 - Old OVK: 20%, VK: 20%
# Rating 100 - Old OVK: 100%, VK: 100%
# Rating 1983 - Old OVK: 100%, VK: 83%
#
# Possible values:
# + Set this option to 1 if you want to use quirky OpenVK behaviour
# + Set this option to 0 if you want to use the canonical VK behaviour
profile.rating-bar-behaviour: 0