From d502f2816ef0fef83c9282caf6c7a91d553b43dc Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Wed, 9 Mar 2022 10:48:22 +0100 Subject: [PATCH] Bug fix --- src/db_models.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/db_models.rb b/src/db_models.rb index 0c6c491..8d246b2 100644 --- a/src/db_models.rb +++ b/src/db_models.rb @@ -1,6 +1,6 @@ # User table model class User < EntityModel - attr_reader :email, :name, :bio_text, :balance, :avatar_url, :pw_hash + attr_reader :email, :name, :bio_text, :balance, :avatar_url, :pw_hash, :reputation def initialize(user_info) super user_info @@ -41,18 +41,14 @@ class User < EntityModel md_parser.render @bio_text end - def reputation - rep = self.get "reputation", "id = ?", @id - rep && rep.to_i - end - def reputation_text - sign = reputation > 0 ? "+" : "" - return "#{sign}#{reputation}" + sign = @reputation > 0 ? "+" : "" + return "#{sign}#{@reputation}" end def reputation= val val = val.clamp MIN_REP, MAX_REP + @reputation = val self.update({reputation: val}, "id = ?", @id) end