Commit graph

109 commits

Author SHA1 Message Date
Gavin D'souza
32bcab40ba
fix(search): Add label only if value exists 2024-09-05 13:48:49 +02:00
Gavin D'souza
0ea610a314
fix: Pass doc.name as label fallback in search_link
Populate desk link titles when relevant information is available via
search_link endpoint
2024-08-30 12:16:29 +02:00
Ankush Menat
4f205e2942
fix: only add title field in search if it exists (#25634) 2024-03-25 05:18:07 +00:00
Corentin Flr
f4b6f95832
fix(search): Don't break when query doesn't return title (#25168) 2024-03-02 19:34:52 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
c476c5e6d7
refactor!: Link field search (#22745)
* refactor!: Drop handling for SQL queries

This hasn't been supported in really long time, no need to check that
use cases.

It will still fail but with no special error message.

* fix: Catch all import related errors

* fix!: Use last query from hooks

* refactor!: Return search results like any other function

Search results are returned in `results` key which is incosistent from
most other functions

* refactor: simplify search_link
2023-10-16 15:41:02 +05:30
Ankush Menat
55a444959e fix: Make search_link query postgres compatible 2023-10-16 11:51:51 +05:30
Ankush Menat
fec7759d00 fix: Give idx higher preference than meta order
Meta order in most cases is default "modified" which doesn't quite help.

idx is # of times a document is referred to somewhere else, which is
more likely to be relevant.
2023-10-16 10:50:57 +05:30
Ankush Menat
31444228c3 fix: Improve search relevance for search_link
When `locate` returns 0 it's shown on top instead it should be shown
last or not shown at all.

This is math hack to avoid using any complex SQL functionality which
isn't allowed in DB query.
2023-10-16 10:46:47 +05:30
Dhia' Alhaq Shalabi
4c415587a6 fix: permission check for the child table in search link
- Using the parent doctype by passing the reference doctype
2023-09-17 15:55:27 +03:00
Dany Robert
237a6697f5
fix: add missing parameters for search_widget (#22052)
* fix: add missing parameters for search_widget

* fix: change to key word params
2023-08-24 16:57:30 +05:30
Ankush Menat
eed90a871b perf!: halve search_link page size
20 results are rarely scrolled by user.

Most users end up typing more characters to narrow down results. This
way on large table we end up reading significantly fewer rows.

The way relational DBs work is they keep filtering and reading rows one
by one until limit is hit, so smaller the limit the better.
2023-07-22 15:09:14 +05:30
Anh Le
8fc518baff fix: repeat title value in description of link field.
(cherry picked from commit 5957cbcf0908261339e64bf6536e5c18af511ea1)
2023-07-03 05:03:54 +00:00
Ankush Menat
8a37d6d278
perf: reduce memory usage of background processes (#21467)
* perf: defer translation.py imports

This indirectly imports babel which isn't really required most of the
time.

* perf: defer gzip import

* perf: move validate_and_sanitize_search_inputs

This causes all sorts of indirect imports and increases memory usage

* perf: defer requests module imports

* perf: defer system settings import

* perf: defer LOG_DOCTYPES import

Causes many indirect imports

* perf: defer update_site_config

* perf: defer notifications import

* perf: remove unused import

* perf: defer safe exec import

* test: memory usage overhead
2023-06-23 12:51:45 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
109a549a23
fix: pass reference_doctype to search query methods (#20842)
frappe.call ensures that it's only passed to functions which can accept
it, so nothing to worry about ~ backward compatible change.
2023-04-25 18:31:14 +05:30
Ankush Menat
b55bbd0a8c
fix(UX): Sort case-insensitive where it makes sense (#20088) 2023-02-20 13:07:32 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Daizy Modi
4d9be26ada fix: use stricter regex for sanitize_searchfield 2022-12-14 16:11:04 +05:30
Sagar Vora
f3c00c2bdc
perf: dont fetch meta unless required (#18907) 2022-11-17 13:15:35 +05:30
Raffael Meyer
11d4cf4396
fix: hide value only if it's equal to the label (#18722) 2022-11-02 13:55:09 +05:30
DrZoidberg09
58cef6005a
fix: search.py after PR #17828 (#18719)
* fix search.py

After the PR #17828 in some cases an "IndexError: list assignment index out of range" error is thrown. This should fix it.

* Update search.py

Yes, that should be even better

* style: formatting

[skip ci]
2022-11-02 13:11:20 +05:30
Raffael Meyer
3d17e1589e
feat: search in translated title, if we show title (#17828)
* refactor: use meta.translated_doctype

* refactor: get_title_field_query

* feat: search in title, if we show title

* refactor: build_for_autosuggest

* style: black

* fix: don't order translated doctypes by untranslated relevance

* feat: match all fields for translated doctypes

* feat: translate all fields in description, remove redundant title

* refactor: title in link

* fix: show name in description for title links
2022-10-12 16:31:53 +05:30
hrwx
42a3fe0fa2 chore: remove untranslated matching 2022-08-12 17:04:37 +01:00
hrwx
b01929405d refactor: translatable doctypes 2022-08-05 21:38:10 +01:00
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Ritwik Puri
d9900d4742 Revert "fix: mention only users that can be read (#16978)"
This reverts commit 576af52ec6.
2022-06-06 13:14:09 +05:30
Raffael Meyer
576af52ec6
fix: mention only users that can be read (#16978)
Full Name and Email ID of a **User** are sensitive data.

With **Role and User Permissions** we can restrict which other users a user can see, thus maintaining data protection. This could be circumvented by using the `@mention` functionality in comments. It allows us to see all users and their names, regardless of our permissions.

This PR aims to fix this issue by using `get_list` instead of `get_all` while retrieving options for `@mention`.
2022-05-24 16:26:34 +00:00
chillaranand
a9492ba5fa refactor: Remove wrapt package
Also replaced inspect.getfullargspec with inspect.signature to
preserve signature of a decorated functions.
2022-04-27 11:36:07 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Raffael Meyer
f80a16ed14
feat: add translated search doctypes to hooks (#16197)
In `search.py` it was hardcoded that **DocType** and **Role** get translated before matching against the search text. This way, a user can type in his local language and still see correct results.

This feature is useful for other DocTypes as well. The criterion would be: there is a small, fairly static number of records, so that the performance impact of translating all names first is not too bad.

This PR adds a hook `translated_search_doctypes` that determines which DocType names get translated before search.

I also added **Country** to `translated_search_doctypes` for frappe. The link to **Country** is frequently used in **Address**, but until now there was no way to use it in the local language. There are ~70% less Countries than DocTypes (including ERPNext), so the performance should be fine.

ERPNext could, for example, add the **Gender** DocType to this hook. As there are very few genders, translating them is fast and improves the UX.

Docs: https://frappeframework.com/docs/v13/user/en/python-api/hooks/edit?wiki_page_patch=b4d7c8d6fc
2022-03-23 10:43:04 +00:00
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
Saqib Ansari
ea3ec5e2a7 Merge branch 'develop' of https://github.com/frappe/frappe into link_title_refactor 2022-01-18 09:52:30 +05:30
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
Saqib Ansari
7c4221df79 feat: show link titles for standard queries 2022-01-13 17:05:14 +05:30
Saqib Ansari
4f340f4aba perf: avoid get_doc while fetching title field 2022-01-13 17:03:54 +05:30
Saqib Ansari
05d80e3b6d refactor: build_for_autosuggest 2022-01-07 18:43:09 +05:30
Saqib Ansari
2b80cabaea chore: remove unused parameter 2022-01-07 16:46:49 +05:30
Saqib Ansari
ab9700d947 Merge branch 'develop' of https://github.com/frappe/frappe into link_title_refactor 2021-12-15 19:32:16 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Mohammad Hasnain Mohsin Rajan
7ab7da5c65
fix: only enabled users in mentions (#14017)
* fix: only enabled users in mentions

* Update frappe/desk/search.py

Co-authored-by: gavin <gavin18d@gmail.com>

* test: add test cases to disallow disabled in mention

* test: pass roles as single values

* style: Remove extra space and line

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: gavin <gavin18d@gmail.com>
2021-08-27 05:09:40 +00:00
hrwx
bee72ee6ff fix: Null query error 2021-08-03 17:15:29 +05:30
hrwx
d056beb0ef feat: show title links in Link Fields 2021-08-03 15:55:32 +05:30
codescientist703
79124873c3 fix: fixed sider recommendation 2021-07-13 18:43:34 +05:30
Gavin D'souza
ba062adca8 refactor(search): Improvements in search_widget, search_link APIs
* Minor perf enhancements
* Renamed sorting_comparator to relevance_sorter
2021-07-08 13:37:39 +05:30
codescientist703
ecfa8c843f fix: child results should appear for parent search query 2021-07-07 17:33:59 +05:30
codescientist703
85bbcaaac4 fix: added sorting and filtering logic for relevant input results 2021-06-23 13:14:17 +05:30
codescientist703
aa6520b5b0 fix: add sorting for paren tree doctype to appear above child 2021-06-23 13:14:17 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30