fix: removed default limit of 25. if null is given all users are fetched or if limit is given limit number of users are fetched

Signed-off-by: yemkareems <yemkareems@gmail.com>
This commit is contained in:
yemkareems 2024-07-04 13:42:37 +05:30
parent cfafbc8415
commit ceedfb4616
4 changed files with 15 additions and 6 deletions

View file

@ -278,7 +278,7 @@ class UsersController extends AUserData {
* 200: Users details returned based on last logged in information
*/
public function getLastLoggedInUsers(string $search = '',
?int $limit = 25,
?int $limit = null,
int $offset = 0,
): DataResponse {
$currentUser = $this->userSession->getUser();

View file

@ -494,12 +494,13 @@ class AllConfig implements IConfig {
/**
* Gets the list of users based on their lastLogin info asc or desc
*
* @param int $limit how many users to fetch
* @param int|null $limit how many users to fetch
* @param int $offset from which offset to fetch
* @param string $search search users based on search params
* @return array of user IDs
*/
public function getLastLoggedInUsers(int $limit = 25, int $offset = 0, string $search = ''): array {
public function getLastLoggedInUsers(?int $limit = null, int $offset = 0, string $search = ''): array {
$limit = $this->fixLimit($limit);
// TODO - FIXME
$this->fixDIInit();
@ -573,4 +574,12 @@ class AllConfig implements IConfig {
public function getSystemConfig() {
return $this->systemConfig;
}
private function fixLimit($limit) {
if (is_int($limit) && $limit >= 0) {
return $limit;
}
return null;
}
}

View file

@ -345,7 +345,7 @@ class Manager extends PublicEmitter implements IUserManager {
/**
* @return IUser[]
*/
public function getUsersSortedByLastLogin(?int $limit = 25, int $offset = 0, $search = ''): array {
public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = ''): array {
$users = $this->config->getLastLoggedInUsers($limit, $offset, $search);
return array_combine(
$users,

View file

@ -253,11 +253,11 @@ interface IConfig {
/**
* Gets the list of users based on their lastLogin info asc or desc
*
* @param int $limit how many records to fetch
* @param int|null $limit how many records to fetch
* @param int $offset from which offset to fetch
* @param string $search search users based on search params
* @return array of user IDs
* @since 30.0.0
*/
public function getLastLoggedInUsers(int $limit, int $offset, string $search): array;
public function getLastLoggedInUsers(?int $limit = null, int $offset = 0, string $search = ''): array;
}