Skip to content

Commit

Permalink
fix: reduce memory consumption while loading users (#191)
Browse files Browse the repository at this point in the history
* fix: reduce memory consumption while loading users

* chore(l10n): update pot file

---------

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
fdalcin and actions-user authored Jul 18, 2024
1 parent 64e6773 commit d9f7e4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
16 changes: 8 additions & 8 deletions languages/pressbooks-multi-institution.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPL v3 or later.
msgid ""
msgstr ""
"Project-Id-Version: Pressbooks Shared Network 1.0.2\n"
"Project-Id-Version: Pressbooks Shared Network 1.0.3\n"
"Report-Msgid-Bugs-To: https://github.com/pressbooks/pressbooks-multi-institution/issues\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-07-17T18:17:48+00:00\n"
"POT-Creation-Date: 2024-07-18T21:42:53+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.10.0\n"
"X-Domain: pressbooks-multi-institution\n"
Expand Down Expand Up @@ -73,27 +73,27 @@ msgid_plural "Users updated."
msgstr[0] ""
msgstr[1] ""

#: src/Controllers/InstitutionsController.php:103
#: src/Controllers/InstitutionsController.php:101
msgid "Action completed."
msgstr ""

#: src/Controllers/InstitutionsController.php:128
#: src/Controllers/InstitutionsController.php:126
msgid "The form is invalid."
msgstr ""

#: src/Controllers/InstitutionsController.php:174
#: src/Controllers/InstitutionsController.php:172
msgid "Institution has been added."
msgstr ""

#: src/Controllers/InstitutionsController.php:175
#: src/Controllers/InstitutionsController.php:173
msgid "Institution has been updated."
msgstr ""

#: src/Controllers/InstitutionsController.php:202
#: src/Controllers/InstitutionsController.php:200
msgid "The name field is required."
msgstr ""

#: src/Controllers/InstitutionsController.php:212
#: src/Controllers/InstitutionsController.php:210
msgid "The book limit field should be numeric."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion resources/views/institutions/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class="regular-text"
@else
<option
value="{{ $user->ID }}"
@if($institution->managers->contains(fn (object $institutionUser) => $institutionUser->user_id === $user->ID)))
@if($institution->managers->contains(fn (object $institutionUser) => $institutionUser->user_id === (int) $user->ID)))
selected
@endif
>
Expand Down
6 changes: 1 addition & 5 deletions src/Controllers/InstitutionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use PressbooksMultiInstitution\Views\InstitutionsTable;
use PressbooksMultiInstitution\Views\InstitutionsTotals;
use PressbooksMultiInstitution\Support\ConvertEmptyStringsToNull;
use stdClass;
use WP_User;

use function Pressbooks\Admin\NetworkManagers\is_restricted;

Expand Down Expand Up @@ -272,7 +270,7 @@ protected function fetchUsers(?Institution $institution): array
->pluck('ID')
->toArray();

$users = get_users([
return get_users([
'blog_id' => 0, // all users from the network
'fields' => ['ID', 'display_name', 'user_email'],
'orderby' => [
Expand All @@ -282,8 +280,6 @@ protected function fetchUsers(?Institution $institution): array
],
'exclude' => $usersToSkip
]);

return array_map(fn (stdClass $value) => new WP_User($value), $users);
}

protected function checkForInvalidDomains(array $domains): array
Expand Down

0 comments on commit d9f7e4a

Please sign in to comment.