Cached some model properties and remove useless eager loading (#253)

* Cached some model properties and remove useless eager loading

* Remove ray call

* Remove double loading of forms

* Add disableCache feature when needed
This commit is contained in:
Julien Nahum
2023-12-02 14:51:08 +01:00
committed by GitHub
parent 8fd85776c6
commit a18077934c
10 changed files with 291 additions and 95 deletions

View File

@@ -34,7 +34,7 @@ class FormController extends Controller
$this->authorize('viewAny', Form::class);
$workspaceIsPro = $workspace->is_pro;
$forms = $workspace->forms()->with(['creator','views','submissions'])
$forms = $workspace->forms()
->orderByDesc('updated_at')
->paginate(10)->through(function (Form $form) use ($workspace, $workspaceIsPro){
@@ -66,7 +66,7 @@ class FormController extends Controller
$this->authorize('viewAny', Form::class);
$workspaceIsPro = $workspace->is_pro;
$newForms = $workspace->forms()->with(['creator','views','submissions'])->get()->map(function (Form $form) use ($workspace, $workspaceIsPro){
$newForms = $workspace->forms()->get()->map(function (Form $form) use ($workspace, $workspaceIsPro){
// Add attributes for faster loading
$form->extra = (object) [
'loadedWorkspace' => $workspace,