From 6f0d36fa67c91d0bd70cf092bd1d41c615e1e8be Mon Sep 17 00:00:00 2001 From: David Beguin Date: Fri, 18 Oct 2019 15:17:41 +0000 Subject: [PATCH] [REF] gamification : rename stat_* fields into granted_* to ease understanding In this commit we rename stat_count into granted_count, and stat_count_distinct into granted_users_count to reflect more what are those variables, aka count of granted badges. Task ID: 1961053 PR #32594 --- addons/gamification/models/badge.py | 16 ++++++++-------- addons/gamification/views/badge.xml | 10 +++++----- .../hr_gamification/views/gamification_views.xml | 2 +- addons/website_profile/controllers/main.py | 2 +- addons/website_profile/views/website_profile.xml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py index bd270113a52..7bfdd074644 100644 --- a/addons/gamification/models/badge.py +++ b/addons/gamification/models/badge.py @@ -107,8 +107,8 @@ class GamificationBadge(models.Model): 'gamification.badge.user', 'badge_id', string='Owners', help='The list of instances of this badge granted to users') - stat_count = fields.Integer("Total", compute='_get_owners_info', help="The number of time this badge has been received.") - stat_count_distinct = fields.Integer("Number of users", compute='_get_owners_info', help="The number of time this badge has been received by unique users.") + granted_count = fields.Integer("Total", compute='_get_owners_info', help="The number of time this badge has been received.") + granted_users_count = fields.Integer("Number of users", compute='_get_owners_info', help="The number of time this badge has been received by unique users.") unique_owner_ids = fields.Many2many( 'res.users', string="Unique Owners", compute='_get_owners_info', help="The list of unique users having received this badge.") @@ -139,8 +139,8 @@ class GamificationBadge(models.Model): the total number of users this badge was granted to """ self.env.cr.execute(""" - SELECT badge_id, count(user_id) as stat_count, - count(distinct(user_id)) as stat_count_distinct, + SELECT badge_id, count(user_id) as granted_count, + count(distinct(user_id)) as granted_users_count, array_agg(distinct(user_id)) as unique_owner_ids FROM gamification_badge_user WHERE badge_id in %s @@ -148,14 +148,14 @@ class GamificationBadge(models.Model): """, [tuple(self.ids)]) defaults = { - 'stat_count': 0, - 'stat_count_distinct': 0, + 'granted_count': 0, + 'granted_users_count': 0, 'unique_owner_ids': [], } mapping = { badge_id: { - 'stat_count': count, - 'stat_count_distinct': distinct_count, + 'granted_count': count, + 'granted_users_count': distinct_count, 'unique_owner_ids': owner_ids, } for (badge_id, count, distinct_count, owner_ids) in self.env.cr._obj diff --git a/addons/gamification/views/badge.xml b/addons/gamification/views/badge.xml index 5dc93d1f921..1115729191f 100644 --- a/addons/gamification/views/badge.xml +++ b/addons/gamification/views/badge.xml @@ -35,7 +35,7 @@ - + @@ -93,9 +93,9 @@ - + - + @@ -117,7 +117,7 @@ - + @@ -141,7 +141,7 @@
Can not grant
- granted, + granted, this month
diff --git a/addons/hr_gamification/views/gamification_views.xml b/addons/hr_gamification/views/gamification_views.xml index 6eddd1171ca..3ce94e91a14 100644 --- a/addons/hr_gamification/views/gamification_views.xml +++ b/addons/hr_gamification/views/gamification_views.xml @@ -7,7 +7,7 @@
-
diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py index 2148f5b78a2..858efd34f16 100644 --- a/addons/website_profile/controllers/main.py +++ b/addons/website_profile/controllers/main.py @@ -180,7 +180,7 @@ class WebsiteProfile(http.Controller): Badge = request.env['gamification.badge'] badges = Badge.sudo().search(self._prepare_badges_domain(**kwargs)) - badges = sorted(badges, key=lambda b: b.stat_count_distinct, reverse=True) + badges = sorted(badges, key=lambda b: b.granted_users_count, reverse=True) values = self._prepare_user_values(searches={'badges': True}) values.update({ diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml index 881bcb7f0da..1b3c85ea599 100644 --- a/addons/website_profile/views/website_profile.xml +++ b/addons/website_profile/views/website_profile.xml @@ -442,7 +442,7 @@
- + awarded users