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

Speed up super admin dashboard #13147

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dacook
Copy link
Member

@dacook dacook commented Feb 13, 2025

What? Why?

It takes so long to load because there's so many enterprises. We don't need to see those.

This has been bugging me since.. forever.

Also did some code cleanup, and removed some unused translation keys.
I tried to use gem i18n-tasks to discover unused keys, but it seemed too risky to clean up too many at once.

If code review passes, maybe it's worth running this past an instance manager too.

What should we test?

  • Go to the admin dashboard as super admin
  • go make a coffee It loads quickly!
  • Scroll to bottom to discover total number of enterprises and click through to browse them all.
  • All text on the admin dashboard page still displays correctly.

  • Go to the admin dashboard as enterprise admin with multiple enterprises (but less than 25)
  • Scroll to bottom, there's no "show all" link.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

@dacook dacook self-assigned this Feb 13, 2025
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I really like that solution of limiting the output without adding a special case for admins. Well done.

@@ -182,6 +182,7 @@ end
group :development do
gem 'debugger-linecache'
gem 'foreman'
gem 'i18n-tasks'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipefurtad0 used this gem before, but without adding it to the Gemfile. Since the configuration is quite important as well and adding this gem keeps coming up it's good that you are doing this properly now.

I doubted the use of this gem before:

So the trade-off is the maintenance and use of this gem vs the benefit. I didn't know that it has that many configuration options. So if we can easily define the patterns of our dynamic keys then this may be worth it.

It would be cool to include automated tests. The tests could detect issues and recommend actions like this:

  • Missing translation found: If this didn't fail a spec then please add spec coverage before adding the translation.
  • Unused translation found: Did you forget to remove this translation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yeah I remembered that PR and thought it was worth considering again.
I like your thinking about how we can automate it.

In the meantime, we can start using it ad-hoc and build up our config as we go.

@mkllnk mkllnk added the user facing changes Thes pull requests affect the user experience label Feb 14, 2025
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up 🧹 !

@drummer83
Copy link
Contributor

Hi @dacook,
Looking forward to this one!
For now there's a conflict. Could you please have a look?
Thanks!

Div is the default element in HAML, so we don't need to specify it.
I thought about reducing it further, but maybe people are used to having a large list. Let's see how this performs
I searched the codebase for these keys, but couldn't find them
The next ones look unused too.
I thought we had a plugin to help with that..
And check fo unused translations:

  bundle exec i18n-tasks unused -l en -f key-values | wc -l
  1277

Wow, really??
That brings the count down to 'only' 1057.

There's probably a lot of other keys that are dynamically generated, I did *not* review them all.
We could consider saving the output of this command to a todo file.
@dacook
Copy link
Member Author

dacook commented Feb 17, 2025

Thanks Konrad, I've fixed the conflict.

@dacook dacook removed the blocked label Feb 17, 2025
@drummer83 drummer83 self-assigned this Feb 21, 2025
@drummer83 drummer83 added the no-staging-AU A tag which does not trigger deployments, indicating a server is being used label Feb 21, 2025
@drummer83 drummer83 removed their assignment Feb 21, 2025
@drummer83 drummer83 removed the no-staging-AU A tag which does not trigger deployments, indicating a server is being used label Feb 21, 2025
@drummer83 drummer83 self-assigned this Feb 24, 2025
@drummer83 drummer83 added no-staging-UK A tag which does not trigger deployments, indicating a server is being used no-staging-AU A tag which does not trigger deployments, indicating a server is being used pr-staged-uk staging.openfoodnetwork.org.uk pr-staged-au staging.openfoodnetwork.org.au pr-staged-fr staging.coopcircuits.fr and removed no-staging-UK A tag which does not trigger deployments, indicating a server is being used no-staging-AU A tag which does not trigger deployments, indicating a server is being used labels Feb 24, 2025
@drummer83
Copy link
Contributor

Hi @dacook,
I've tested this PR on all three staging servers.
The performance improvement is amazing!! ⚡

Average loading times (10 runs):

Server Before After
Staging AU n.a. (see below) n.a. (see below)
Staging FR 19234 ms 381 ms
Staging UK 9552 ms 279 ms

Regarding AU: Here the test requests from Postman are automatically redirected to the /admin/enterprises page. The redirection also happens when entering /admin in the browser manually. I think this is due to some configuration or user settings. I didn't dig into it deeper, because the performance improvement can be seen on the other servers.

Here is a screenshot of the new and shorter list of enterprises:
image

As you can see, there are 25 of more than 4000 enterprises listed. ✔️
However, there is no "display all" button or some sort of pagination. I couldn't find a way to see more enterprises in that list. ❌

Did I miss anything?

I will move this back to In Progress for you to have a look.
Thanks! 🙏

@drummer83 drummer83 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Feb 24, 2025
@drummer83 drummer83 removed pr-staged-au staging.openfoodnetwork.org.au pr-staged-fr staging.coopcircuits.fr labels Feb 24, 2025
@drummer83 drummer83 removed their assignment Feb 24, 2025
@dacook
Copy link
Member Author

dacook commented Feb 24, 2025

Thanks for the feedback Konrad!
To keep things simple, I didn't add a new link, because you can click on "Manage my enterprises" to get to the enterprise list page.

I wasn't sure if we could communicate it better.

  • I thought maybe it should say "MANAGE ALL MY ENTERPRISES", but if the pagination is not active, that would sound weird.
  • Or maybe there could be an additional link on the pagination line. Eg: "Showing 25 of 4043. Manage all my enterprises."

Ultimately, it's only power users who would have more than 25 enterprises, so they can probably work it out themselves ;)

What do you think?

@dacook
Copy link
Member Author

dacook commented Feb 24, 2025

AU Staging

I just tried it and it works fine for me. I don't know of any config that would cause that behaviour.

I just looked, and found there is logic to redirect to enterprises screen if it's your "first access" of the admin interface. If:

        outside_referral && incomplete_enterprise_registration?

So maybe you just need to go to the homepage first and click on Administration in the menu. Or you might need to set up a new enterprise.

@drummer83
Copy link
Contributor

To keep things simple, I didn't add a new link, because you can click on "Manage my enterprises" to get to the enterprise list page.

Thanks David, I understand your point but I'm still hesitant. Some people use Ctrl + F to find a certain enterprise in the very long list of enterprises. This won't work anymore without the possibility to load the full list. It also doesn't work anymore on the enterprises list page, because we've introduced pagination there as well.

I think we should ask @RachL and @tschumilas for their opinions on this.

I could imagine that adding the link is not a lot of work?

@dacook
Copy link
Member Author

dacook commented Feb 26, 2025

Some people use Ctrl + F to find a certain enterprise in the very long list of enterprises. This won't work anymore without the possibility to load the full list. It also doesn't work anymore on the enterprises list page, because we've introduced pagination there as well.

A very good point! I would argue that the pagination on the dashboard is more important than on the Enterprises page, so would suggest if anything, we remove pagination from that page.
But it would be better to provide a search input. For this use-case, I would suggest we have a dropdown that allows you to quickly filter and select the desired enterprise (like pictured), then when you select it, it takes you to the enterprise edit page.
Screenshot 2025-02-26 at 5 39 16 pm

What do you think of that? I can imagine it would be useful on both the Dashboard and the Enterprise list page. The only thing is it could potentially take a couple of hours work.

I could imagine that adding the link is not a lot of work?

You're right, it's a simple change. The hard thing is deciding how to word it. If you make a suggestion I'll go ahead and add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback-needed user facing changes Thes pull requests affect the user experience
Projects
Status: In Progress ⚙
Development

Successfully merging this pull request may close these issues.

4 participants