Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Auto Attendance processing #517

Merged
merged 6 commits into from
May 16, 2023

Conversation

ruchamahabal
Copy link
Member

@ruchamahabal ruchamahabal commented May 16, 2023

Auto attendance job times out with scale.

Before:

perf-auto-attendance-before

After:

Tested with data: 1000 employees, 10,000 check-ins

perf-after

Optimizations:

  • Added simple indexing on widely queried columns to avoid full table scans: Shift Type and Employee in Employee Checkin
  • get_doc -> db_exists or get_value
  • db.get_all -> db.exists or get_value
  • Caching: get_cached_doc / get_cached_value / get_value with db_cache (as per use case_

- `get_doc` -> `get_cached_doc` / `get_value`

- `get_value` to `db.value_cache`
@codecov-commenter
Copy link

Codecov Report

Merging #517 (2971dc1) into develop (7579a94) will increase coverage by 0.01%.
The diff coverage is 66.66%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #517      +/-   ##
===========================================
+ Coverage    73.03%   73.04%   +0.01%     
===========================================
  Files          190      190              
  Lines         9842     9839       -3     
===========================================
- Hits          7188     7187       -1     
+ Misses        2654     2652       -2     
Impacted Files Coverage Δ
hrms/hr/doctype/shift_type/shift_type.py 90.90% <33.33%> (ø)
...ms/hr/doctype/employee_checkin/employee_checkin.py 93.54% <100.00%> (ø)
...ms/hr/doctype/shift_assignment/shift_assignment.py 91.37% <100.00%> (ø)

... and 2 files with indirect coverage changes

- get_list makes no sense here since its a scheduled job and perms should not be checked

- only select required fields
- early return if no employee found

- reuse filters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants