From 5c9c09c7a90164671eac18cc8d0a1c5d6765501e Mon Sep 17 00:00:00 2001 From: Celestora Date: Sat, 9 Oct 2021 22:42:20 +0300 Subject: [PATCH] Refactor rating bar --- Web/Models/Entities/User.php | 10 ++++++++-- Web/Presenters/templates/User/View.xml | 4 ++-- quirks.yml | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 36b0681a..ead200f9 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -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, ]; } diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index f1768ba8..43c7da15 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -122,8 +122,8 @@
{var completeness = $user->getProfileCompletenessReport()} -
-
+
+
{$completeness->total}%
diff --git a/quirks.yml b/quirks.yml index e69de29b..e2e5473a 100644 --- a/quirks.yml +++ b/quirks.yml @@ -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