-3

I've started to work on a project with the new company that I work for, some part of my job definition is to maintain existing website yet my experience on the used technologies is limited I can even say it's slim to none. The problem that I'm facing now is a seemingly easy problem yet I wasn't able to solve it so far.

Our system contains users and user licenses along with other stuff, whenever we try to edit a user license we are facing a particular problem that slows down our process arithmetically with the number of users rising.

Whenever we click on the edit action on the licenses page for an individual user, instead of just listing a basic edit form with only information about the selected user and license, it instead queries all the users and creates a list with all the users we have when we try to edit the license for 1 individual only. This is how our edit page looks like at the moment in below:

Edit license page

this user list basically consists of every single user in our database so it's leads us to have such queries fired after clicking the edit action.

Number of queries

I'm working with a limited number of users in my local to be able to work at least but it gets more dramatic with more data of course. I'll now share a quick snapshot from our easy_admin.yml file to show the current structure.

Easy_admin.yml file related parts

and the just a part of a License entity where we access the user.

License entity

The User entity itself is fairly larger and since my first goal is to find a way around without changing the entities really I won't publish it here now, but if that's no way around without such a change I can also share it too.

Our license listing page is using the same structure too as you can probably see yet the reason that we don't face that overwhelming slowness in the same page is we're using the pagination feature of the easyadmin while listing the licenses and we are using the "max_result: X" for that purpose, I thought maybe I could limit that to only one user on our edit page too but when I try that I have faced with the problem that has explained in detail in here:

“You cannot define a mapping item when in a sequence” when running phpunit in symfony

The thing I would like to know is if there is a way around in easy_admin.yml that can help me to fix that problem issue without making many changes in the entity itself, I'm basically trying to create an edit page like the show page with only the information of the user that is being edited, or basically a way to create overall better queries to solve the problem once and for all. Example pages to visualize what I meant:

License show page for and individual

Or like our user edit page here:

User edit page

Thanks in advance for all the answers and the attempts of help.

  • can you provide the action and the form used to dsiplay this page? And the related twig if any? – Florent Cardot Mar 11 '21 at 12:21
  • @FlorentCardot Hello Florent thanks for the answer. We are using the built-in "edit" action that is provided by the easyadmin for all 1.x versions: https://symfony.com/doc/1.x/bundles/EasyAdminBundle/book/actions-configuration.html. Now that I've noticed that I did not mention about the symfony and easyadmin versions. Symfony: 4.4.16, easyadmin: 1.7.24 – Eren Akbulut Mar 11 '21 at 12:34
  • Ok, so basicaly, you want the field user not to be editable or just to display the user? To avoid all these query? – Florent Cardot Mar 11 '21 at 12:42
  • @FlorentCardot Basically what I want is to not to run a query that brings all the users when I click on an individual license's edit action. This is our current edit page from the above: [link](https://i.stack.imgur.com/Mijg2.png) what I want is basically just seeing the user who owns the license when I click on the edit license, not all the users queried and served as options like in the screenshot above ( when I click on the User dropdown I can view all the users) – Eren Akbulut Mar 11 '21 at 13:02

1 Answers1

0

I would remove 'user' under license/list/fields in your yaml, and add the user name in the title of the form. See https://symfony.com/doc/1.x/bundles/EasyAdminBundle/book/edit-new-configuration.html#customize-the-title-of-the-page

Florent Cardot
  • 1,400
  • 1
  • 10
  • 19
  • Thanks a lot for the answer Florent, I tried that one before actually but wouldn't removing the user from that part of the yml file break the adding a new license process, when I tried that I was able to edit pretty quickly as I intended but adding a new user became impossible that way. – Eren Akbulut Mar 11 '21 at 13:08