Commit Graph
11 Commits
Author SHA1 Message Date
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Guillaume (gdi) 00189db5ec [FIX] website_event_track_quiz: keep search filter on page change
Before this commit, following these steps:
- Have more than 30 attendees for an event
- Go to the event page
- Click on community
- Search for a letter that is in the +30 attendees names
- Go to the second page of search results

=> We lose the filtering of the attendees by the letter. This commit
allows to keep the filters when the user is on a result page and
changes page.

task-3058239

X-original-commit: 2c7d923b11f2c31c3ae2137a7ff9baf0b58c0be6
Part-of: odoo/odoo#114253
2023-03-03 15:56:48 +01:00
Victor Feyens 1a1ce16265 [IMP] core,*: check routes decorators
When overriding an existing controller route, developers can
easily c/p the route definition and call super() in the overridden method
when the route attributes are automatically deducted by odoo from the parent route.

Removing those redefined attributes simplifies the routes definition,
clearly highlighting what's changed by the override.
Also reduces unexpected behavior when modifying the base route without
noticing/considering the redefined attributes in a overridden route,
which overrides the changes made to the base route when the sub-module is installed.

This commit adds a test to catch routes attributes redefinition, and clean existing routes.

closes odoo/odoo#108512

Related: odoo/enterprise#35176
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-01-16 19:45:57 +01:00
Romain Derie d348bed1ad [IMP] website, *: use upsert to improve visitor perf
* im_livechat, test_event_full, website_blog, website_crm,
  website_event, website_event_track, website_event_track_quiz,
  webite_livechat, website_sale

There is 6 main changes in this commit:

1. Using raw SQL Upsert instead of the ORM methods. While raw SQL should
generally be avoided, it makes sense for such a low level behavior which
is impacting every flows.
Indeed, tracking visitors is a generic behavior done on all pages and
controllers. It is important to optimize it to reduce processing time
and SQL Queries.
Benchmark of that change alone:
> Rendering a tracked page improves from ~19.5ms to ~17ms (using `ab`
  with 1000 loop) and the requests involved in the tracking process are
  reduced from 8 SQL Queries to 3:
  - 1 request to upsert the visitor
  - 1 request to fetch the visitor data
  - 1 request to add the tracking record

2. Adding in that upsert query the `visitor.track` insert, creating both
records in one go, bringing the query count from 3 to 2.

3. Refactoring of the `parent_id` behavior that was introduced in stable
with [1]. The purpose was to keep track of multiple visitor linked to a
same user to merge the tracking together. Especially useful for tracking
a same visitor on different devices (when logged in).
Only one visitor was kept as active, others would be archived and their
tracks would be set/moved to the main partner.
Removing those duplicate visitor was not possible because those archived
duplicated visitor were holding the devices notification push token.
Since [2], those token were moved to their own table, all related to the
main visitor.
We can then now safely remove those duplicate visitors after merging
their track to the main visitor. Thus, the `parent_id` field is no more
useful. Removing it removes a layer of complexity.
Note that thanks to this part, the `active` field can also be removed.

4. Deeper functionnal change, inspired from Plausible: The access_token
is no more stored in a cookie but is the result of a hashing method
based on <IP Adress, User Agent>.
The reason behind that change is that, in an upcoming refactoring,
sessions won't be stored anymore unless absolutely needed (login, add to
cart..). It will also ship a no cookies policy, trying to get rid of all
cookies.
This change is bringing some functional changes:
- Since the IP is included in the hash to generate the token, it means
  that:
  A. If an anonymous user switch IP (eg from 4G to wifi), it is
     considered as a new visitor.
  B. If 2 anonymous users with the exact same user agent (same browser,
     same browser version, same exact os or phone) are on the same IP,
     those will be considered as the same visitor.
- Since the request host is not included in the hash, it means that
  visiting a DB from 2 differents URLs (domain and/or ip) on the same
  device and same browser will result in a shared visitor.
  It shouldn't imply any issue as this is A. not wrong and B. mostly
  used for tests.
As all this is only related to non logged in user, it shouldn't be a
real issue as anonymous visitors are not supposed to be meant to be
business critical, even if we use them for "a bit more" than simple
analytics data.

5. The access_token is now replaced by the partner_id once the user logs
in, so:
- We don't need to either search on the partner_id field or the
access_token field (depending if the user is logged in or not), we can
only use the access_token row/field to do both.
- On logout, everything works out of the box as the access_token will be
regenerated since there is no partner_id anymore.
- On login, if an access_token matches the user's partner_id, that
visitor is returned.
If there is no such token, a new visitor is created for that partner_id.
In both 2 cases, tracks are moved to that visitor and the anonymous
visitor is removed.
- We can remove the code that was in charge of checking if the
access_token / visitor cookie was wrong (coming from another user eg,
different user login on same device). Indeed, such collision is not
possible anymore as the access_token automatically match the logged in
user.
- We can remove the code that was in charge of checking if the
access_token / visitor cookie was wrong (coming from a logged in user
while the current visitor is not loggedin). Such collision is not
possible anymore as the access_token is (re)generated as an anonymous
token (hash) when not logged in.

6. There is no more check to prevent a track to be created if there was
already a track for that URL in the last 30 minutes.
While this can easily be re-introduced (one CTE on the upsert), it was
adding ~100ms (from ~20 to ~110ms) to the request on a big database as
Odoo where there is ~100 millions tracks and ~100 millions visitors.
It has been validated that it was not a real issue as it is not
fundamentally wrong. If a visitor visited 20 times a product or a
specific page in that short amount of time, you might want to know that
because the user is most likely interested by it.

Changes (1+2), 3, (4+5) and 6 are all independant from each other and
could have existed on their own.

[1]: https://github.com/odoo/odoo/commit/c6b8a44b970a46dcd87a4e2cb1ad52fa340b209f
[2]: https://github.com/odoo/enterprise/pull/16781/commits/f75090fe8b42484e89e933976e8441d2f5eb9415

task-2867045

closes odoo/odoo#87857

Related: odoo/enterprise#28004
Related: odoo/upgrade#3566
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-06-07 16:31:20 +02:00
Thomas Carlier f45cd217c1 [FIX] event_track_quiz : fix quiz validation error
Steps to reproduce the bug:

- Config/Settings > "Event Gamification" needs to be enabled >
- Go to an event E > Tracks, select one with a quiz > View on website > Do quiz
- On website > Go to E > click Take the Quizz > Fill the answers
- Check the answers

Bug:

 Error was raised saying need to answer all questions instead of showing correct vs incorrect answers

opw:2733275

closes odoo/odoo#90873

X-original-commit: 5f15f76e6a9467c245af1d4804d773cce59d902b
Signed-off-by: Simon Goffin <sig@odoo.com>
2022-05-09 15:01:11 +02:00
Victor Feyens 24f9af3fd0 [IMP] *: remove Trailing newlines (C0305)
Part-of: odoo/odoo#86332
2022-04-27 07:51:23 +02:00
Julien Banken 4fb38e2876 [IMP] website_event_track[_live]_quiz: allow multiple tries & improve layouts
When the user submits a quiz, the user will not get much feedback. To
improve the user experience, we will now indicate how many points the
users earned per question. With that information, the users could detect
errors and report them to the administrators. We will also add some
minor layout improvements to make things clearer.

When the administrator creates a quiz, the administrator might not want
to set a limit on the number of attempts that a user can have on a quiz.
To allow that, we added an option in the quiz settings called 'Unlimited
Tries'. When the administrator checks that option, a button will appear
below the quiz and will let the users reset the quiz at will.

Sometimes, the administrator might also want to (1) give points for an
answer that is not wrong or (2) give no point for a correct answer. This
is not currently possible as we considered that the correct answer is the
answer that rewards points. To allow that, we will add a new boolean
field on each answer to mark the correct answer.

task-2504216

COM PR: odoo/odoo#69585
UPG PR: odoo/upgrade#2408
2021-09-02 07:32:24 +00:00
Thibault Delavallée de8a5652b2 [REM] website_event_track_session: merge into website_event_track
PURPOSE

Clean organization and models linked to Event Online feature introduced in
semi stable saas-13.3 at odoo/odoo@981f95bbf4 and odoo/enterprise@14722028ae

Also clean website event menu not being available in website event but only
in website event track, which implies some extra-code to manage it.

In short: merge website_event_online in website_event, website_event_track
_(online/session) in website_event_track.

RATIONALE

_online modules have been added to extend content of website_event and
website_event_track without having any impact on those module. First step
of cleaning is to move this content directly in base module.

track_session module is mainly a rewrite of track module. Second step of
cleaning is to move its content directly in website_event_track.

SPECIFICATIONS

Move all content of website event track session to website event tracK. It
was mainly of rewriting of views and can now be safely merged into the base
track module.

Update dependencies accordingly.

LINKS

Task ID-2319779
COM odoo/odoo#56067
ENT odoo/enterprise#12520
UPG odoo/upgrade#1654
2020-08-21 17:30:13 +00:00
Thibault Delavallée 77d7a3cf6a [MOV] website_event(_track): move website event menu into website event
PURPOSE

Clean organization and models linked to Event Online feature introduced in
semi stable saas-13.3 at odoo/odoo@981f95bbf4 and odoo/enterprise@14722028ae

Also clean website event menu not being available in website event but only
in website event track, which implies some extra-code to manage it.

In short: merge website_event_online in website_event, website_event_track
_(online/session) in website_event_track.

RATIONALE

_online modules have been added to extend content of website_event and
website_event_track without having any impact on those module. First step
of cleaning is to move this content directly in base module.

track_session module is mainly a rewrite of track module. Second step of
cleaning is to move its content directly in website_event_track.

SPECIFICATIONS

Move website event menu model directly into website event. Website event menu
model has been introduced to help dealing with event-specific menus and
website menus. This is some kind of glue to synchronize both of them as people
could either

  * update an event (website_menu, website_track) that updates website menus
    availability;
  * update menus through website that should update event field value and menu
    computation;

Having a model introduced in website event track forces to have override and
code split across website_event, website_event_track, and now also in both
_online version of those two as menu management was improved.

In this commit we simplify all this code by moving most of menu management
code in website_event, leaving only business-specific code (fields and their
menus) to sub modules.

SPECIFICATIONS: WEBSITE EVENT MENU

Make type required as we don't support entries without type. Indeed this model
is used to automate menus generation / destruction, and not for hand-made
menus. We therefore set type as required and add a cascade ondelete for
selection.

SPECIFCIATIONS: COMMUNITY MENU

Doing this change allows to define community menu in website_event and re-use
it in website_event_meet and website_event_track_quiz, removing some
unnecessary dependencies. This menu is void in website_event, and displays
either meeting rooms (in meet) or quiz points leaderboard (in quiz), or a
mix of both if the two features are installed.

LINKS

Task ID-2319779
COM odoo/odoo#56067
ENT odoo/enterprise#12520
UPG odoo/upgrade#165
2020-08-21 17:30:13 +00:00
Thibault Delavallée f236fdfe52 [IMP] website_event_track_quiz: add visitor_track fields on views
It allows to help debugging and could also allow to change gained points in
case some tweaking is necessary.

LINKS

Coming from internal feedback while deploying online support
Task ID-2314778
PR #55634

X-original-commit: 6d81690ff77dfbae74128cc2cbd875b2b3074823
2020-08-14 12:06:11 +00:00
fe17857e89 [ADD] website_event_track_quiz: add quiz feature on event.track
RATIONALE

Events are sometimes held online, gathering a community. In this merge we
improve Event application to better support full-online events with improved
tracks, wishlists, chat rooms, ...

PURPOSE

Allow to configure a quiz on event tracks, much like eLearning.
The quiz is taken at the end of the live stream / track video.
(Or when the talk is 'live' of 'done').

SPECIFICATIONS

Users can now configure an event.quiz on event.track.

The quiz is a simple collection of event.quiz.questions that in turn contain
a few event.quiz.answers.
Only one of the answer is considered as correct and should be configured with
"awarded_points" greater than 0.

On the event.track frontend page, attendees can take the quiz when the track
is "live" (or "done") and earn the total amount of configured awarded_points.
Each quiz can only be taken once (if you fail, you can't try again).

Attendees are then ranked in a leaderboard that is displayed in the "Community"
section of the event frontend menus.
The leaderboard allows to see your own position as well as basic search for
other attendees.
The points earned during the event are event-specific and will not be shared
with other instances of event.event.

Points as well as quiz completion are stored in the relationship between a
visitor and a track (event.track.visitor).

The models are very much based on a similar feature in website_slides, even
though the implementation in event is not karma based.
We will probably have to merge the features later into a base gamification_quiz
module.

LINKS

Task ID-2252655 (Main Online Event task)
Task ID-2283771 (Quizzes on Talks, Leaderboard)

Co-Authored-By: Aurélien Warnon <awa@odoo.com>
Co-Authored-By: David Beguin <dbe@odoo.com>
Co-Authored-By: Quentin Mourier <qmo@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2020-08-04 14:28:29 +00:00