Commit graph

48645 commits

Author SHA1 Message Date
Ankush Menat
47fd3386fd
Revert "fix: Always reset globals on cached templates (#30897)" (#30906)
This reverts commit 32c1220c31.
2025-01-28 10:02:00 +00:00
Akhil Narang
531efc893f
Merge pull request #30899 from akhilnarang/fix-auto-repeat
fix(auto_repeat): take end date into consideration
2025-01-28 13:21:30 +05:30
Akhil Narang
41820d8f89
Merge pull request #30898 from akhilnarang/disable-attach-child-new-doc
fix: don't allow attaching a file to a child table in a new document
2025-01-28 13:13:55 +05:30
Akhil Narang
4b26b107a1
fix(auto_repeat): take end date into consideration
Otherwise we wouldn't add the end date in the schedule

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-28 13:10:48 +05:30
Akhil Narang
2fdc94840f
fix: don't allow attaching a file to a child table in a new document
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-28 12:37:18 +05:30
Ankush Menat
32c1220c31
fix: Always reset globals on cached templates (#30897) 2025-01-28 05:59:57 +00:00
Akhil Narang
baf884d31f
Merge pull request #29888 from akhilnarang/bench-browse-updates
feat: fixed session duration + better visibility of changes done via `bench browse`
2025-01-28 11:22:54 +05:30
Raffael Meyer
4d041c1231
feat(Data Import): delete Data Import Log on trash (#30893) 2025-01-27 16:38:57 +01:00
Raffael Meyer
829a1404da
chore: bump actions/cache to v4 in boilerplate (#30889) 2025-01-27 12:01:09 +00:00
Akhil Narang
dcb58ab5c7
Merge pull request #30884 from akhilnarang/fixup-29172
fix: use strip_html() instead of escape_html()
2025-01-27 16:54:19 +05:30
Akhil Narang
4ef8629228
fix: use strip_html() instead of escape_html()
escape_html() removes `'`, which can be used in names

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-27 16:45:14 +05:30
Suraj Shetty
00914da9ce
Merge pull request #30045 from iamejaaz/child-table-lagging 2025-01-27 13:07:00 +05:30
Ankush Menat
078330485c
fix: Re-update jinja globals on cached templates (#30882) 2025-01-27 07:08:25 +00:00
Ejaaz Khan
b12e42f406 fix: add missing px in style 2025-01-27 11:56:49 +05:30
Ankush Menat
23694b6b3b
fix: Don't cache pages with query params (#30881)
This was always broken apparantly. Cache key only contains the path so
querystring is being ignored. If request has query params then we
shouldn't cache it.

WIP - better solution for caching based on cache headers. Anyway this
caching isn't THAT helpful since #29170
2025-01-27 06:22:43 +00:00
Ejaaz Khan
756670d675 refactor: optimize grid selection by reusing existing reference 2025-01-27 10:57:57 +05:30
Ejaaz Khan
e76cb990ab refactor: add scroll to current element, remove grid loop 2025-01-26 12:24:46 +05:30
Ankush Menat
9b79dfeb7b
perf: "random" naming to improve concurrency and locality (#30053)
This feels overengineered and it kinda is, but other efforts to
inroduce sequential naming/UUID naming haven't been that fruitful
either.

10 character random "hash" i now changed to.

1. first character - last character in UUID4 ID of request/job
2. three characters - derived from current timestamp.
4. 6 characters - random data.

This satisfies all three requirements:

1. Readers - temporal locality should result in spatial locality on disk. (fewer pages accessed)
2. Single writer - temporal locality should result in spatial locality. (fewer dirty pages)
3. Multiple writers - temporal locality should NOT result in spatial locality. (less lock contention)

Mostly concludes https://github.com/frappe/frappe/pull/25309 and https://github.com/frappe/frappe/pull/28349

Rough probabiliy numbers

Assumptions:
- Unique per worker prefix - 16 (uuid's base16 version)
- Rough time spent generating names - 10% of request (very very conservative estimate)

Probability(collision) = P(at least one prefix collision) * P(time collision)
Probability(collision) = (1 - p(all different)) * 10%
Probability(collision) = (1 - (16! / 16-N! )/ 16^N ) * 10%

| N (concurrency) | Probability(collision) |
| 1  |    0.0% |
| 2  |    0.6% |
| 3  |    1.8% |
| 4  |    3.3% |
| 5  |    5.0% |
| 6  |    6.6% |
| 7  |    7.9% |
| 8  |    8.8% |
2025-01-25 07:04:09 +00:00
Ankush Menat
473ff81a31 fix(UX): change cursor for clickable list count 2025-01-25 11:07:30 +05:30
Ankush Menat
a2d43aed66
Merge pull request #30050 from ankush/count_kill
perf: Hard-limit `get_count` runtime to 1 second
2025-01-25 10:32:26 +05:30
Ankush Menat
67fafdd812 perf: Set timeout in same query / avoid side effects 2025-01-25 10:22:08 +05:30
Ankush Menat
6ea200a48f fix: handle typical client tracking errors 2025-01-25 10:15:50 +05:30
Ankush Menat
658e6c5e73 perf: Hard-limit get_count runtime to 1 second
We have limited count to 1000 by default but this can still easily read
entire table if:
- There are filters and filters don't use index and there aren't 1000
  matching rows.

This unknown tail latency by default is not acceptable, so by default
any count query that fails to return results in 2 seconds will be
terminated and user will have to explicitly ask for the count.
2025-01-25 10:15:48 +05:30
Chris Francis
727a639ab1
Corrected Grammar in the CODE_OF_CONDUCT.md file (#29889) 2025-01-24 20:20:02 +01:00
Raffael Meyer
ba53d18642
Merge pull request #30051 from barredterra/mapper-perms-2 2025-01-24 20:05:48 +01:00
barredterra
015c9425ed Revert "fix: don't skip perm check when Apply Strict User Permissions is enabled (#29916)"
This reverts commit 4a0ccf6d76.
2025-01-24 19:56:44 +01:00
Raffael Meyer
10b429ffd6
Merge pull request #29132 from barredterra/fix-datetime-utils 2025-01-24 17:24:41 +01:00
Ankush Menat
d9081f170b
feat: HTTP caching on API endpoints (#29997)
* fix: update instead of extend

None of these are supposed to be extended over defaults.

* feat: custom response header support

* refactor: use response_headers to set cache control headers

* feat: Decorator to cache API response using cache-control headers

* perf: cache notifications for 1 minute

+ SWR for 5 minutes

* perf: cache `get_events` on desk load

* perf: slow down auto-refresh even more

once every 5 seconds instead of 2 seconds.

* perf: Cache plain link validation for 30 minutes

Very often you're picking same documents again and again, there's no
need to validate them.

Also, document is JUST selected using search_link, so it's 99%
guaranteed to be valid.

The real purpose of this function is to provide "fetch from" feature,
not link validation like the name suggests.

It will get validated server side anyway.

* fix: Never use HTTP cache in developer mode

* perf: cache "is_document_amended"

A document that is amended from something stays amended.

* perf: proxy-cache website_script.js

* fix: only cache if called directly
2025-01-24 20:04:57 +05:30
Ankush Menat
57633f1387
fix(DX): add faulthandler for SEGV and other bad signals (#30046) 2025-01-24 14:24:54 +00:00
Ankush Menat
266b510c88 test: skip HTTP caching in tests 2025-01-24 19:53:30 +05:30
Ankush Menat
6328421fde fix: only cache if called directly 2025-01-24 19:08:04 +05:30
Ankush Menat
0a068e28f7 perf: proxy-cache website_script.js 2025-01-24 18:58:39 +05:30
Ankush Menat
5cf5f66fec perf: cache "is_document_amended"
A document that is amended from something stays amended.
2025-01-24 18:58:39 +05:30
Ankush Menat
153c38571f fix: Never use HTTP cache in developer mode 2025-01-24 18:58:39 +05:30
Ankush Menat
1470ad2a66 perf: Cache plain link validation for 30 minutes
Very often you're picking same documents again and again, there's no
need to validate them.

Also, document is JUST selected using search_link, so it's 99%
guaranteed to be valid.

The real purpose of this function is to provide "fetch from" feature,
not link validation like the name suggests.

It will get validated server side anyway.
2025-01-24 18:58:36 +05:30
Soham Kulkarni
c067fd4b62
fix: remove whitespace from restrict ip and always check request_ip (#29867)
* fix: remove whitespace in restrict ip in validate

* fix: added check for request_ip

* fix: return if no restrict ip

* fix: set to localhost if none, refactor validate_ip_addr

* fix: validate ip_address cleanup and removed uncessary comments

* fix: validate ip_addr cleanup

* fix: remove unecessary check
2025-01-24 13:12:58 +00:00
Ankush Menat
daf4885f0a perf: slow down auto-refresh even more
once every 5 seconds instead of 2 seconds.
2025-01-24 18:35:26 +05:30
Ankush Menat
2b1df9aa56 perf: cache get_events on desk load 2025-01-24 18:35:26 +05:30
Ankush Menat
f177bb28a7 perf: cache notifications for 1 minute
+ SWR for 5 minutes
2025-01-24 18:35:26 +05:30
Ankush Menat
378b638d34 feat: Decorator to cache API response using cache-control headers 2025-01-24 18:35:26 +05:30
Ankush Menat
32054b0757 refactor: use response_headers to set cache control headers 2025-01-24 18:35:26 +05:30
Ankush Menat
f30159adc6 feat: custom response header support 2025-01-24 18:35:26 +05:30
Ankush Menat
33d6ea94b8 fix: update instead of extend
None of these are supposed to be extended over defaults.
2025-01-24 18:35:26 +05:30
Akhil Narang
a9c1c49fff
refactor: use an alternate key for handling expiry
This allows for less changes to update() + allows impersonated sessions to not end later

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 18:27:44 +05:30
Ejaaz Khan
d01eb3a18e refactor: remove unwanted log code 2025-01-24 17:45:01 +05:30
Ejaaz Khan
cbcf921dfb fix: recursive call of handle scrollbar function 2025-01-24 17:33:51 +05:30
Akhil Narang
15065a93e3
refactor: don't use impersonate directly, use similar logic
This will allow impersonating as well

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Akhil Narang
1dc767f671
feat(browse): allow passing a user for impersonated_by
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Akhil Narang
332e22f00b
refactor: fix typo in impersonated
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Akhil Narang
a121b90d7f
feat: allow created a session for a fixed duration via bench browse
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30