perf: optimize DB calls with frappe.get_all (#45289)
* perf: reduce multiple db queries
* fix: use frappe._dict instread of extra iteration
---------
Co-authored-by: Sanket322 <shahsanket322003.com>
(cherry picked from commit 2a400dd3f8)
Co-authored-by: Sanket Shah <113279972+Sanket322@users.noreply.github.com>