summaryrefslogtreecommitdiff
path: root/addons/website/tests/test_performance.py
AgeCommit message (Collapse)Author
2020-09-17[FIX] core: non-stored binary fields should have attachment=FalseRaphael Collet
This prevents some code (in controllers) to retrieve an attachment for a field that is not stored, as the code only relies on `field.attachment`. This also makes the field definition more consistent. closes odoo/odoo#57969 X-original-commit: 13397943d9e953815ae5ce9b01ce812a92903361 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-09-03[IMP] base,website*: do not store country flags.Victor Feyens
1) Avoid the storage of all country flags as ir_attachment (230+ ir_attachment in a new db) to reduce the filestore of databases. The country flags are nearly static and not expected to be modified on Odoo instances. This change is based on the new "image_url" widget logic (see previous commits). 2) Extend the flag coverage for countries Add the missing country flags & specify a mapping to provide flags for overseas administrated countries/territories.
2020-08-21[IMP] website: perf - cache public pageJeremy Kersten
closes odoo/odoo#56331 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-07-24[FIX] website: adapt query countRaphael Collet
closes odoo/odoo#54878 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-11[FIX] website, website_blog: adapt testsRaphael Collet
closes odoo/odoo#52865 X-original-commit: ae268ec99e25d246593b3996981b4287a0ed3081 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-03-30[IMP] website: improvement regarding social imageRomain Derie
This commit introduce multiple improvements regarding social image: - (perf) Don't read ir.attachment through `social_default_image` when it is not needed. Use a stored boolean to know if the field should be accessed. This will remove one SQL query in attachment for public user. - Show website logo, not the company logo since we now have a different logo for website. - Don't show images lower than 200 width or 200 height px. Logo will be shown regardless of his size. - Don't show website logo if there is a website social_default_image. Indeed, the spec was to prevent showing logo and social_default_image if they are the same image. Technically, this is hard to identify as they could be the same image uploaded with different resolutions (media dialog), especially if one of those was uploaded through the backend and one from the frontend. It is most likely we will never correctly identify duplicate as they won't be exactly the same. For this reason, it makes more sense to hide the website logo if the social_default_image is set. It avoids every issues while it makes sense since you won't want to use the logo over the social_default_image. If you really want to, you could reupload it through the SEO media dialog. closes odoo/odoo#47848 Related: odoo/upgrade#1012 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com> Co-authored-by: Romain Derie <rde@odoo.com> Co-authored-by: Jeremy Kersten <jke@odoo.com>
2020-03-26[IMP] http_routing: use cached code from langJeremy Kersten
In case of short controller that don't use qweb template, we don't need anyhting else that this url code that don't change frequently. It make only sense for model like lang, website, ... that will not change frequently. And are called on each call by the dispatcher. In case of a website page, we will btw browse lang later, but in case of small controller like /favicon.ico, or page without qweb, ... we can just use the same from last query.
2020-03-26[FIX] base: perf - binary_record, don't rebrowse ir.attachmentJeremy Kersten
If model is already an ir.attachment we don't need to do a new search_read. We can use it record directly. After this commit, we don't do extra request if we already have the info, else we don't change the behavior. task-2211013
2020-03-26[IMP] website: perf - add cache for website frequent fieldsJeremy Kersten
The dispatching layer of Odoo (common to any call) can avoid a query on website if those 3 values are cached. Note that for complex business flows, there won't be any gain since website infos will have to be fetched at some point. About user_id: In most cases, for a website page you will need to browse the website btw so we don't remove this request previously. But in case of a simple image, the controller /web/content need the public user just to set the request.uid in auth_public but no other info from website. With this commit, we don't do the 'select * from website where id in()' request on each controller declared in auth='public' but use the user_id from the cache. (Invalidated by the write on website_id) task-2211013 Co-authored-by: Jérémy Kersten <jke@odoo.com> Co-authored-by: Romain Derie <rde@odoo.com>
2020-03-26[IMP] base: perf - try/except instead of existsRomain Derie
Most of the time, the record exists, but we still ensure it does, every single time, making an SQL query. Doing a try catch will result in the same behavior, but won't make that query most of the time. task-2211013
2020-03-26[IMP] website: perf - prefetch menus when serving a pageRomain Derie
If we are rendering a page, the menus will most likely be rendered as well. Note that even in a 403 case when the page is found but is not visible, the menus will also be shown on the 403 page. Fetching the menus before accessing the requested page will prefetch that page as well in one go if that page is in the menus, without any costs for the pages not in the menus. There is a tradeoff for 'non-layout' pages, which only occurs in advanced technical cases: 1. Create a page with specific extension as name suffix (page.css) in which case the page will be bootstraped accordingly, without call to layout. 2. Remove the call to layout in HTML editor or backend 3. Remove the call to submenus template in HTML editor or backend For those cases, the menus will be prefetched for no reason. Note that homepage '/' is rendered through a controller, same logic is applied there. task-2211013
2020-03-26[IMP] website: perf - clear cache only when neededRomain Derie
Before this commit, the cache would always been cleared even if not needed. Now, we only clear cache when needed. Util: Introduced with https://github.com/odoo/odoo/commit/9920f20e4c7753bc17bea71dea3a90f7de687196#diff-1407a8ce197a04eefaefa26c127a4418R327 Changed with 0d5fcdc1c7d1 task-2211013
2020-03-26[IMP] website: perf - reduce SQL queries for the website menuRomain Derie
Render page flow: - Search website.page in _serve_page for requested URL - Check if the page is visible with `is_visible` - `is_visible` will get the `ir.ui.view` of the page Note that this is not 'cachable' as being visible depends of now() for the publishing date - Render layout which is getting the website menus Note that this can't be cached either as a menu visibility might also depends of it's website.page visibility which depends of now() - Checking menus `is_visible` fetch the menus pages and those pages views. Before this commit, every level of menu hierarchy would add 2 queries. This can be avoided by prefetching everything in once during the dispatch if we know we will render the website menu. In such a case, read `is_visible` on every website menus will fetch every pages, views and menus in the lowest SQL queries possible, eg one query for every table. For a 3 level menus, requests goes from 20 to 12 to load a untracked page. task-2211013
2020-03-26[IMP] website: clean and add perf testsRomain Derie
- Refactor for easier readability - Add a test to ensure menu hierarchy scale correctly. - Add tests for image controllers - Add test for assets controllers task-2211013
2020-03-19[FIX] website: add SQL performance test for page loadingRomain Derie
This will ensure the performances stay correct for a blank page (no layout), a standard page and a homepage (which has its own controller). Related to #47257 task-2211013 X-original-commit: 08e01b5fc4a71b8f7639a953137fbb546ddf3b3e