Reduce number of SQL queries when doing groups sync

This commit is contained in:
Frédéric Guillot
2018-10-02 15:15:23 -07:00
parent 5cce000f95
commit c06a110830
2 changed files with 30 additions and 17 deletions

View File

@@ -45,10 +45,10 @@ class GroupModel extends Base
}
/**
* Get a specific group by external id
* Get a specific group by externalID
*
* @access public
* @param integer $external_id
* @param string $external_id
* @return array
*/
public function getByExternalId($external_id)
@@ -56,6 +56,22 @@ class GroupModel extends Base
return $this->db->table(self::TABLE)->eq('external_id', $external_id)->findOne();
}
/**
* Get specific groups by externalIDs
*
* @access public
* @param string[] $external_ids
* @return array
*/
public function getByExternalIds(array $external_ids)
{
if (empty($external_ids)) {
return [];
}
return $this->db->table(self::TABLE)->in('external_id', $external_ids)->findAll();
}
/**
* Get all groups
*