mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Ajout d'une boucle sur l'envoie des queries pour diminuer le temps d'attente
This commit is contained in:
parent
57ef2d341c
commit
063f0c97a3
1 changed files with 26 additions and 20 deletions
|
@ -444,30 +444,36 @@
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$webhookQueries = $db->getFromTableWhere('webhook_queries', ['progress' => false]);
|
for ($i = 0; $i < 30; $i++)
|
||||||
$webhookQueriesIds = [];
|
|
||||||
foreach ($webhookQueries as $webhookQuerie)
|
|
||||||
{
|
{
|
||||||
$webhookQueriesIds[] = $webhookQuerie['id'];
|
$webhookQueries = $db->getFromTableWhere('webhook_queries', ['progress' => false]);
|
||||||
}
|
$webhookQueriesIds = [];
|
||||||
|
foreach ($webhookQueries as $webhookQuerie)
|
||||||
|
{
|
||||||
|
$webhookQueriesIds[] = $webhookQuerie['id'];
|
||||||
|
}
|
||||||
|
|
||||||
$db->updateProgressWebhookQueriesIn($webhookQueriesIds, true);
|
$db->updateProgressWebhookQueriesIn($webhookQueriesIds, true);
|
||||||
|
|
||||||
foreach ($webhookQueries as $webhookQuerie)
|
foreach ($webhookQueries as $webhookQuerie)
|
||||||
{
|
{
|
||||||
//On remap les datas
|
//On remap les datas
|
||||||
$datas = json_decode($webhookQuerie['datas'], true);
|
$datas = json_decode($webhookQuerie['datas'], true);
|
||||||
$datas = http_build_query($datas);
|
$datas = http_build_query($datas);
|
||||||
|
|
||||||
//On fait la requete
|
//On fait la requete
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_URL, $webhookQuerie['url']);
|
curl_setopt($curl, CURLOPT_URL, $webhookQuerie['url']);
|
||||||
curl_setopt($curl, CURLOPT_POST, 1);
|
curl_setopt($curl, CURLOPT_POST, 1);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
|
||||||
curl_exec($curl);
|
curl_exec($curl);
|
||||||
curl_close($curl); //On ferme CURL
|
curl_close($curl); //On ferme CURL
|
||||||
|
|
||||||
echo "Query do to " . $webhookQuerie['url'] . " with datas " . $datas . "\n";
|
echo "Query do to " . $webhookQuerie['url'] . " with datas " . $datas . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//On attend 2 secondes
|
||||||
|
sleep(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue