Commit Graph
21 Commits
Author SHA1 Message Date
Florian Charlier 466ab1eee6 [IMP] gamification, *: imp selection of cron-updated goals
*: base

In the cron updating challenges goals, we were historically filtering
in records of users that logged in since the last update. This doesn't
work because sessions can last a long time, so users are active between
cron runs but their goals are not updated and stale reports were sent.

We temporarily fixed this in v14.0 by updating all goals for internal
users, but this can lead to unnecessary computations too, and still
misses goals of active portal users.

Instead, we are here using the `bus.presence` records to track user
activity, combining it with the session lifetime to avoid indefinitely
fetching old goals that couldn't need an update.
This works for both internal and portal users.

Note: we update stale base comments in favor of exposing bus.presence
to guide developers.

Task-3148858

closes odoo/odoo#121763

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-05-30 19:09:55 +02:00
Florian Charlier dbb251f1e0 [FIX] gamification: update internal users goals
For performance reason, we avoided computing goals for the set of users
that didn't log in recently (See ec0c0f29).
However, users can stay logged in for a while without having a new "log
in event" (password asked), such that active internal users can keep
old values in their challenges when reports are sent, which is not good.

Until an improvement can be implemented in master, we drop this time
constraint for active internal users.

A test is added, checking the behavior of the method called by the cron.

Task-3226408

closes odoo/odoo#121506

X-original-commit: 6c77dd822c719a2181bac1d69130e5c4e8ef70fa
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-05-16 14:42:31 +02:00
Thomas Josseandstd-odoo 0ffa2d64ba [IMP] gamification, website_forum, website_slides: karma tracking improvement
Purpose
=======
Some users found a way to farm karma points, so we want to be able to
track the source of the karma gain / loss.

Specifications
==============
Now, we added a reference field `origin_ref` which store the record
responsible for the karma gain / loss (e.g. a slide we just completed).

In addition to this origin, we also have a new field to store the
reason (e.g. "Slide completed") so we know exactly what happened and
how the user gains his karma.

Before, the `old_value` of the karma tracking has to be set manually,
but now it's done automatically based on the value of the previous
tracking of the same user. That way, it will simplify other part of
the code.

Add the karma reason in the website modules. Adapt those modules due
to the changes in gamification.

Task-2234179

closes odoo/odoo#76430

Related: odoo/enterprise#23702
Related: odoo/upgrade#3299
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Co-authored-by: std-odoo <std@odoo.com>
2023-03-06 17:47:09 +01:00
Xavier-Do 503ed05029 [IMP] tests: add generic Basecase.start for patch
Using patcher.start() can easily lead to incorrect cleanup.
-> after a copy paste, patcher is working, but stop is forgotten
-> stop is present, but won't be called if something fails during the
test

This commit add an utility `start(patcher)` to always have the add
cleanup.

Using a standard way to start the patcher with an automated addCleanup
should prevent this kind of mistake. This is why this commit also
replaces all valid patch.start() (followed immediately by a addCleanup)

closes odoo/odoo#102873

X-original-commit: 7d5a193d86316965a0908c65cfacfb607dc3f3ad
Related: odoo/enterprise#32618
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-10-10 16:11:01 +02:00
Raphael Collet 1398b6b44c [IMP] tests: deprecate SavepointCase
closes odoo/odoo#62031

Related: odoo/enterprise#14872
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-11-24 13:23:32 +00:00
Thibault Delavallée 1404af789c [REF] various: use helper to create tests users
PURPOSE

Lessen use of mail-specific calls and variables

SPECIFICATIONS

Use mail_new_test_user tool in tests, lessening use of mail-specific context
keys in tests.

LINKS

Task ID-2326281 (context keys use cleaning)
PR odoo/odoo#56631
PR odoo/enterprise#12707

X-original-commit: 910559c092dc7dfa00b91339a5423e16cd4668e1
2020-08-28 07:59:23 +00:00
Odoo's Mergebot cfc65bd1b7 [MERGE] various: Make the test suite demo data independant
Purpose
=======

This is the first huge step to improve the test suite in several ways:

- Make them demo data independent, allowing to modify the demo data without having to adapt the tests depending on it. It also allows to have a beautiful + convenient demo dataset to make a demonstration, and to configure complex data in the tests to manage the corner cases.
- Improve the test performances by converting them into SavepointCase. Each test will be rollbacked to it's initial state, after the setUpClass call. That way the different data are not re-created at each test for nothing.
- Introduce several test classes in base/tests/common.py to launch a TransactionCase, HttpCase or SavepointCase test with an available demo user, portal user or a large set of partners.
- This is the first step to tend to a rolling release process, allowing to execute the tests (or a subset of the tests) on a migrated base, for example.

closes odoo/odoo#39868

Taskid: 2075739
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-11-07 08:37:12 +01:00
Aurélien Warnon 3773a0c552 [IMP] gamification: add sql constraint to force rank's min_karma > 0
This commit adds a SQL constraint to force the min_karma of the gamification.karma.rank model to be
above 0.

A karma_min set to 0 (or lower) could create some frontend issues when displaying required karma.

PR #39870
Task#2032649
2019-11-06 13:01:13 +00:00
Yannick Tivisse f82dea5ffe [IMP] gamification: Adapt tests to work with/without demo data 2019-11-05 13:08:03 +01:00
Thibault Delavallée c5b7e00065 [IMP] gamification: merge karma related tests in the same file and improve rank tests
Purpose is to have all karma related tests in the same file to ease finding
them back. Some tweaking is also done like using a savepoint case and ensuring
tests can always be re-run.

LINKS

Task ID 2003505
PR #34594
2019-11-05 15:08:34 +00:00
Patrick Hoste bfbc7c6a18 [IMP] gamification: track karma change on users
PURPOSE

Allow karma gain tracking enabling notably display of top users based on
weekly / monthly gain in website profile.

SPECIFCIATIONS

Each time a user gains karma a record is created in the gamification karma
tracking model. Scheduled activity runs to consolidate the records into
monthly gain records to avoid having crowdy table and unnecessary noise
in karma gain.

This model is made private and only accessible through some dedicated
compute methods / controllers used in website profile.

In website profile module buttons are added to see users ranking based
on their total karma (like before) but also by last week and last month
gains (using the newly introduced tracking model).

LINKS

Task ID 2003505
PR #34594
2019-11-05 15:08:34 +00:00
Jeremy Kersten 8a80efd7cd [FIX] gamification: perf on write karma_min on gamification.karma.rank
This commits avoid to call recompute when you write on the rank without
touch the karma_min value.

On write on karma_min, we have 2 cases:
- Rank order are the same, just need to recompute the rank for the user
that could be impacted. Eg. if karma_min changes from 45 to 50, we need
to recheck for all user between 45 and 50 their new rank.
- Rank order are not the same, we need to recompute for all users.
(could be still improved if needed)

When you recompute the rank on a list of users, depending of the number of
users (bulk if more than 3 * number of rank) we check for each user what is
the new rank, or for each rank whats is the new users.

task-internal

No way to edit a rank on the prod server. Lock sql -> crash server

closes odoo/odoo#34835

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-24 09:03:13 +00:00
Christophe Monniez 3ff0948b0a [FIX] gamification: compute badge stats wihtout error
Since 960360a, when computing badge stats, a datetime was compared to a
string leading to a traceback.  e.g. when clicking in employess >
badges.

Also, due to a typo, the compute method was assigning the stats result
to the wrong attributes.  e.g. 'stats_my_this_month' instead of
'stat_my_this_month'.

With this commit, the above mentioned issues are fixed and a test is
covering these issues to avoid regression.
2018-08-22 09:28:16 +02:00
Xavier Morel 0c649644db [MIG] gamification: Migrate to new API
Includes compatibility-change to website_forum: a selection(callable)
converted to a Selection(list) since that can easily be extended in the
new API.
2016-08-05 10:18:02 +02:00
Martin Trigaux eb18cad599 [FIX] gamification: avoid name clash with update
update is a method from the ORM with a different signature.
Avoid name clash. Issue 646610
2015-10-07 16:29:00 +02:00
Olivier Dony 0bd4545348 [LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate text
- Preserved explicit 3rd-party copyright notices
- Explicit boilerplate should not be necessary - copyright law applies
  automatically in all countries thanks to Berne Convention + WTO rules,
  and a reference to the applicable license is clear enough.
2015-06-02 03:16:04 +02:00
Xavier Morel 65cd4a2a33 [FIX] remove deprecated checks/fast_suite test attributes from standard modules 2015-01-15 14:31:40 +01:00
Martin Trigaux 36acee7568 [FIX] gamification: test needs cron to run
bzr revid: mat@openerp.com-20140416153153-f6r85uc8ibztzvup
2014-04-16 17:31:53 +02:00
Martin Trigaux 90ebde3676 [FIX] gamification: remove old calls to action_close
bzr revid: mat@openerp.com-20131224152902-i2ozrf41y1ou2vdm
2013-12-24 16:29:02 +01:00
Martin Trigaux 13bfaef3a3 [FIX] gamification: remove old calls to action_start
bzr revid: mat@openerp.com-20131224151543-oofn9wc2w3933gjy
2013-12-24 16:15:43 +01:00
Martin Trigaux e7887b8b8f [REF] gamification: python tests and other improvements
bzr revid: mat@openerp.com-20131218111243-npnauv6mxhb4nttg
2013-12-18 12:12:43 +01:00