Commit graph

42220 commits

Author SHA1 Message Date
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Sagar Vora
b6669bb56e
perf: remove localproxy for frappe.cache (#21281)
* perf: remove localproxy for `frappe.cache`

* chore: fix type hints
2023-06-08 10:21:45 +05:30
Ankush Menat
40b3cd82bc
feat!: frappe.cache() -> frappe.cache (#21279)
This is more intuitive and consistent with other things like `frappe.db`.

PS: This is quite likely to break some weird usage which I can't guess right now. Normal usage inside request/job cycles will continue to work as it used to.
2023-06-07 22:47:45 +05:30
Ankush Menat
2cb2934f96
perf: query queued_recipients only once (#21277)
O(N) -> O(1) check for queued recipients

Caused by https://github.com/frappe/frappe/pull/18044

Co-authored-by: Suraj Shetty <surajshetty3416@gmail.com>
2023-06-07 18:05:06 +05:30
Daizy Modi
984963d75e
chore: remove unused get_docname (#21270) 2023-06-07 13:56:50 +05:30
Shariq Ansari
226cebe3b4
Merge pull request #21265 from shariquerik/workflow-builder-breadcrumbs 2023-06-07 13:01:16 +05:30
Shariq Ansari
1607eb9ef3 fix: added breadcrumbs on workflow builder page 2023-06-07 09:57:43 +05:30
Ritwik Puri
094b8589f7
chore: add skipped in list view for patch log (#21264) 2023-06-07 00:01:52 +05:30
Ankush Menat
34ee6a1677
fix: declare the function (#21261)
[skip ci]
2023-06-06 16:11:02 +05:30
Shariq Ansari
c515b29c5e
Merge pull request #21252 from shariquerik/workspace-content-duplicating-fix
fix: avoid loading workspace content if already loaded
2023-06-06 09:11:53 +05:30
Shariq Ansari
f6cad90304
Merge branch 'develop' into workspace-content-duplicating-fix 2023-06-06 08:07:44 +05:30
Shariq Ansari
4f459f7146 fix(unrelated): make create doctype using form builder default button 2023-06-06 08:07:01 +05:30
Ankush Menat
90fd748592
fix(UX): Notify if newly created user has no roles (#21251)
- System user with no role is useless
- By default adding a new system user doesn't give them ANY role so
they can't really access desk even if they have system user role.
2023-06-05 22:27:01 +05:30
Shariq Ansari
4506a91380
Merge pull request #21245 from shariquerik/small-text-url-fix 2023-06-05 22:23:58 +05:30
Shariq Ansari
42ead7dc91
Merge branch 'develop' into workspace-content-duplicating-fix 2023-06-05 22:17:27 +05:30
Shariq Ansari
ba9e2aab17 fix: avoid loading workspace content if already loaded 2023-06-05 22:11:42 +05:30
Shariq Ansari
bda86629ee
Merge branch 'develop' into small-text-url-fix 2023-06-05 19:17:20 +05:30
Suraj Shetty
e5524ba477
Merge pull request #16561 from alyf-de/map-read-only 2023-06-05 17:57:02 +05:30
Shariq Ansari
2358bd8fc1 fix: changed for section with features and testimonial web temlates 2023-06-05 15:18:06 +05:30
Shariq Ansari
64613fec48 fix: changed section with card url field to small text 2023-06-05 15:11:46 +05:30
gn306029
54fabab010
fix: currency formatter got incorrect format when use precision 0 (#21239)
* fix: currency formatter got incorrect format when use precision 0

* Revert "fix: currency formatter got incorrect format when use precision 0"

This reverts commit 1919cf4763b16e0cca2c2596223443d901e00e27.

* fix: allow 0 as default precision

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-06-05 12:34:17 +05:30
Ankush Menat
a7413fe4a7 chore: separate out func call key for @redis_cache 2023-06-04 15:13:39 +05:30
Ankush Menat
392a506a76 perf: Cache published web forms 2023-06-04 15:13:39 +05:30
Ankush Menat
c94c0591c3 perf: cache dynamic web pages 2023-06-04 15:13:39 +05:30
Ankush Menat
7c7c11b454 perf: Cache web view routes
Each call to evaluate if route is web view makes N queries where N = #
of web view doctypes. This entire computation can be definitely cached
for short duration.

- Added cache bursting in WebsiteGenerator doctype updates.
- Added 60 minutes TTL in case cache invalidation wasn't done reliably.
2023-06-04 15:13:39 +05:30
Ankush Menat
e30b823eeb fix!: Webhook naming should be prompt 2023-06-04 10:46:38 +05:30
Suraj Shetty
f0df450c6f
Merge pull request #21224 from surajshetty3416/fix-safe-eval 2023-06-04 09:24:10 +05:30
Suraj Shetty
65a2cdcffc fix(safe_eval): Normalize code passed before validating the code 2023-06-04 08:59:08 +05:30
Ankush Menat
26722b1a1c fix: ignore ConnectionError in frappe.cache().exists() 2023-06-03 22:53:10 +05:30
Ankush Menat
0d056a3a2b test: fix broken tests
Fixture test:
This is broken cause it's trying to find doctype after it has been
deleted (wut?)
It was working so far because cache wasn't cleared correctly so you'd
still find it from cache.

db.set_value test:
converted to use last query instead of patching SQL
2023-06-03 22:53:10 +05:30
Ankush Menat
84ef2cc89c fix: reliable cache clearing for doctype
reclear cache after commit to prevent stale caching.
2023-06-03 22:53:10 +05:30
Ankush Menat
7d50ef19d3 perf: Delete multiple keys in O(1) redis calls
Currently we call redis for each key, redis already supports deleting
multiple keys in one go.
2023-06-03 22:53:10 +05:30
Ankush Menat
4193a251a5 fix: Invalidate cache on rollback too
Steps:
    - Document modified
    - Document refetched from cache
    - Transaction rolled back
    - Cache now contains unmodified changes.
2023-06-03 22:53:10 +05:30
Ankush Menat
98b4693dcf perf: finer cache eviction on db.set_value
Instead of nuking everything, just clear matching prefix
2023-06-03 22:53:10 +05:30
Ankush Menat
356a2587e2 refactor: Use plain keys instead of hashes for caching
- Hashes are supposed to be used for representing complex object, not
  multiple documents of same DocType.
- Redis's auto cache clearing wont clear individual key from hashes even if they
  are rarely used.
- Keys can have expiry.
2023-06-03 22:53:10 +05:30
Ankush Menat
106ff1f1ee fix: move cache clearing away from document
Passing lambda function from inside document object would keep reference
to document alive. This means increasing memeory usage in bulk
processing.

Refer https://github.com/frappe/frappe/pull/17061 for example

This also extends it to db.set_value
2023-06-03 22:53:10 +05:30
Ankush Menat
be1da0dd00 chore: remove duplicate cache clearing 2023-06-03 22:53:10 +05:30
Ankush Menat
339cbf208c fix: Cache clearing implementation 2023-06-03 22:53:10 +05:30
Ankush Menat
6717b07ab9 perf(customize_form): rebuild global search in bg 2023-06-03 22:28:35 +05:30
Ankush Menat
07e1d34568 refactor: RQ enqueue after commit and tests 2023-06-03 18:44:19 +05:30
Ankush Menat
0b9dee4791 test: db callbacks 2023-06-03 18:44:19 +05:30
Ankush Menat
54ae0c4a21 refactor: move flush_realtime_log to realtime.py
This doesn't have anything to do with databases
2023-06-03 18:44:19 +05:30
Ankush Menat
6ce7444669 refactor: generic callback manager 2023-06-03 18:44:19 +05:30
Ankush Menat
680cf73cba fix: link_count
This didn't work correctly, if link_count is present in cache it would
just read and dump it back in.

This has practically never worked correctly.
2023-06-03 18:44:19 +05:30
Ankush Menat
3f1c66de10 refactor: move flush_local_link_count to hook 2023-06-03 18:44:19 +05:30
Ankush Menat
ccc107b41f test: use db.before_commit 2023-06-03 18:44:19 +05:30
Ankush Menat
6519651002 refactor: change implementation of enqueue_after_commit
if enqueue_after_commit then pass partial function after commit instead
of storing it in flags. SLIGHTLY less efficient, but uses consistent API.
2023-06-03 18:44:19 +05:30
Ankush Menat
b3d370a0b1 refactor!: remove rollback_observers
use `frappe.db.after_rollback.add` instead
2023-06-03 18:44:19 +05:30
Ankush Menat
7e9ef00bea refactor!: Remove frappe.db.add_before_commit
Not used anywhere, use `frappe.db.before_commit.add()` instead.
2023-06-03 18:44:19 +05:30
Ankush Menat
235e4855c2 feat: DBHooks to run things before/after commit/rollback
This is a common pattern which is implemented in inconsistent and undocumented ways using these:

- `frappe.local.rollback_observers`
- `frappe.flags.enqueue_after_commit`
- `frappe.local.realtime_log`
- `frappe.local.before_commit`
- `flush_local_link_count`

Instead new simple api:

- Simple function call `frappe.db.after_commit.run(function)`
- If you need args just pass partial function `frappe.db.after_commit.run(lambda: frappe.clear_cache(doctype, name)`
2023-06-03 18:44:19 +05:30