-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added faster fetching of members and units from DB table instead of Profile data.
- Loading branch information
Showing
4 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* Request a list of members from the DB table Members. | ||
* By not specifying "resources", the API interprets that the desired | ||
* response is simply a list of content-types items. | ||
*/ | ||
|
||
require_once __DIR__ . '/../src/UniwebClient.php'; | ||
|
||
use Proximify\Uniweb\API\UniwebClient; | ||
|
||
$client = new UniwebClient(UniwebClient::loadCredentials()); | ||
|
||
$units = $client->queryUnits(['sortBy' => 'memberCount']); | ||
$unit = array_pop($units); // last unit | ||
|
||
if (!$unit) { | ||
throw new Exception("Cannot find a unit"); | ||
} | ||
|
||
$unitId = $unit['contentId']; | ||
|
||
|
||
// If "recourses" is not given, the query will fetch from a DB table | ||
// of the requested content type. That is the fastest type of query. | ||
// Profile resources are comparatively slower. | ||
$request = [ | ||
'action' => 'read', | ||
'contentType' => 'members', | ||
'filter' => [ | ||
'units' => [$unitId] | ||
] | ||
]; | ||
|
||
$response = $client->sendRequest($request); | ||
|
||
$unitName = $unit['unitName']; | ||
$client->printResponse($response, "List of members in unit '$unitName':"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters