mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-05-13 03:26:26 +02:00
Add strategy for more efficient pagination in API listing of entries by using before_id and after_id wheres instead of pagination if possible
This commit is contained in:
parent
04b0f1267a
commit
0e11bcda17
10 changed files with 156 additions and 28 deletions
controllers/internals
|
@ -66,7 +66,7 @@ class Queue extends \descartes\InternalController
|
|||
*
|
||||
* @return mixed $message : The oldest message or null if no message found, can be anything
|
||||
* @param ?string $tag : A tag to associate to the message for routing purposes, if null will read from general queue
|
||||
* @param mixed : The message to add to the queue, can be anything, the queue will have to treat it by itself
|
||||
* @param mixed : The message return from the queue, can be anything, null if no message found
|
||||
*/
|
||||
public function read(?string $tag = null)
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ use Exception;
|
|||
$this->bdd->beginTransaction();
|
||||
|
||||
$id_received = $this->get_model()->insert($received);
|
||||
if (!$id_received)
|
||||
if (!$id_received)
|
||||
{
|
||||
$this->bdd->rollBack();
|
||||
|
||||
|
|
|
@ -77,12 +77,14 @@ namespace controllers\internals;
|
|||
* @param int $id_user : User id
|
||||
* @param ?int $nb_entry : Number of entry to return
|
||||
* @param ?int $page : Pagination, used to calcul offset, $nb_entry * $page
|
||||
* @param ?int $after_id : If provided use where id > $after_id instead of offset
|
||||
* @param ?int $before_id : If provided use where id < $before_id instead of offset
|
||||
*
|
||||
* @return array : Entrys list
|
||||
*/
|
||||
public function list_for_user(int $id_user, ?int $nb_entry = null, ?int $page = null)
|
||||
public function list_for_user(int $id_user, ?int $nb_entry = null, ?int $page = null, ?int $after_id = null, ?int $before_id = null)
|
||||
{
|
||||
return $this->get_model()->list_for_user($id_user, $nb_entry, $nb_entry * $page);
|
||||
return $this->get_model()->list_for_user($id_user, $nb_entry, $nb_entry * $page, $after_id, $before_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue