AntonLV há 8 anos atrás
pai
commit
33ad6eceb0

+ 28 - 6
inc/classes/BxDolQueue.php

@@ -11,7 +11,8 @@ class BxDolQueue extends BxDolFactory
 {
     protected $_oQuery;
 
-    protected $_bBusy;
+    protected $_sParamTime;
+    protected $_iExecutionLiveTime;
 
     protected $_iLimitSend;
     protected $_iLimitSendPerRecipient;
@@ -25,7 +26,8 @@ class BxDolQueue extends BxDolFactory
 
         parent::__construct();
 
-        $this->_bBusy = false;
+        $this->_sParamTime = '';
+        $this->_iExecutionLiveTime = 86400;
     }
 
     /**
@@ -37,6 +39,28 @@ class BxDolQueue extends BxDolFactory
             trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
     }
 
+    public function getBusy()
+    {
+        return (int)getParam($this->_sParamTime);
+    }
+
+    public function setBusy($iTime = 0)
+    {
+        setParam($this->_sParamTime, $iTime);
+    }
+
+    public function isBusy()
+    {
+        $iNow = time();
+        $iTime = $this->getBusy();
+
+        $bBusy = !empty($iTime) && ($iNow - $iTime) < $this->_iExecutionLiveTime;
+        if(!$bBusy)
+            $this->setBusy($iNow);
+
+        return $bBusy;
+    }
+
     /**
      * Send some number of items (email/push) from queue
      *
@@ -45,11 +69,9 @@ class BxDolQueue extends BxDolFactory
      */
     public function send($iLimit = 0)
     {
-        if($this->_bBusy)
+        if($this->isBusy())
             return false;
 
-        $this->_bBusy = true;
-
         $aSent = array();
 
         if(empty($iLimit))
@@ -63,7 +85,7 @@ class BxDolQueue extends BxDolFactory
     	        $aSent[] = $iId;
             }            
 
-        $this->_bBusy = false;
+        $this->setBusy();
 
     	return count($aSent);
     }

+ 2 - 0
inc/classes/BxDolQueueEmail.php

@@ -15,6 +15,8 @@ class BxDolQueueEmail extends BxDolQueue implements iBxDolSingleton
 
         $this->_oQuery = new BxDolQueueEmailQuery();
 
+        $this->_sParamTime = 'sys_eq_time';
+
         $this->_iLimitSend = (int)getParam('sys_eq_send_per_start');
         $this->_iLimitSendPerRecipient = (int)getParam('sys_eq_send_per_start_to_recipient');
     }

+ 2 - 0
inc/classes/BxDolQueuePush.php

@@ -15,6 +15,8 @@ class BxDolQueuePush extends BxDolQueue implements iBxDolSingleton
 
         $this->_oQuery = new BxDolQueuePushQuery();
 
+        $this->_sParamTime = 'sys_push_queue_time';
+
         $this->_iLimitSend = (int)getParam('sys_push_queue_send_per_start');
         $this->_iLimitSendPerRecipient = (int)getParam('sys_push_queue_send_per_start_to_recipient');
     }

+ 2 - 0
install/sql/system.sql

@@ -274,6 +274,8 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'sys_cron_time', '_adm_stg_cpt_option_sys_cron_time', '0', 'digit', '', '', '', 2),
 (@iCategoryId, 'sys_install_time', '_adm_stg_cpt_option_sys_install_time', '0', 'digit', '', '', '', 3),
 (@iCategoryId, 'sys_revision', '_adm_stg_cpt_option_sys_revision', '0', 'digit', '', '', '', 5),
+(@iCategoryId, 'sys_eq_time', '_adm_stg_cpt_option_sys_eq_time', '0', 'digit', '', '', '', 6),
+(@iCategoryId, 'sys_push_queue_time', '_adm_stg_cpt_option_sys_push_queue_time', '0', 'digit', '', '', '', 7),
 
 (@iCategoryId, 'sys_ftp_login', '_adm_stg_cpt_option_sys_ftp_login', '', 'digit', '', '', '', 10),
 (@iCategoryId, 'sys_ftp_password', '_adm_stg_cpt_option_sys_ftp_password', '', 'digit', '', '', '', 11),

+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1304,6 +1304,7 @@
 	<string name="_adm_stg_cpt_option_sys_embedly_api_key"><![CDATA[Embed.ly API key (fill in to use instead of Iframely)]]></string>
 	<string name="_adm_stg_cpt_option_sys_embedly_api_pattern"><![CDATA[Embed.ly API pattern (fill in to use instead of Iframely)]]></string>
 	<string name="_adm_stg_cpt_option_sys_iframely_api_key"><![CDATA[Iframely API key]]></string>
+        <string name="_adm_stg_cpt_option_sys_eq_time"><![CDATA[Last execution time of email queue]]></string>
 	<string name="_adm_stg_cpt_option_sys_eq_send_per_start"><![CDATA[Number of messages to send from mail queue per run]]></string>
         <string name="_adm_stg_cpt_option_sys_eq_send_per_start_to_recipient"><![CDATA[Number of messages to send from mail queue per run to the same recipient]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_key"><![CDATA[UNA account key]]></string>
@@ -1318,6 +1319,7 @@
     <string name="_adm_stg_cpt_option_sys_push_rest_api"><![CDATA[REST API Key]]></string>
     <string name="_adm_stg_cpt_option_sys_push_short_name"><![CDATA[Short name (required only for http sites. It must match the Subdomain you entered on the Web Push settings on the OneSignal dashboard)]]></string>
     <string name="_adm_stg_cpt_option_sys_push_safari_id"><![CDATA[Apple Safari Web ID on the Web Push settings]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_queue_time"><![CDATA[Last execution time of push queue]]></string>
     <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start"><![CDATA[Number of messages to send from Push queue per run]]></string>
     <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start_to_recipient"><![CDATA[Number of messages to send from Push queue per run to some recipient]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_sid"><![CDATA[Account SID]]></string>

+ 2 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1302,6 +1302,7 @@
     <string name="_adm_stg_cpt_option_sys_embedly_api_key"><![CDATA[Ключ Embed.ly API (заполните, чтобы использовать вместо Iframely)]]></string>
     <string name="_adm_stg_cpt_option_sys_embedly_api_pattern"><![CDATA[Шаблон Embed.ly API (заполните, чтобы использовать вместо Iframely)]]></string>
     <string name="_adm_stg_cpt_option_sys_iframely_api_key"><![CDATA[Ключ Iframely API]]></string>
+    <string name="_adm_stg_cpt_option_sys_eq_time"><![CDATA[Дата последнего запуска имейл очереди]]></string>
     <string name="_adm_stg_cpt_option_sys_eq_send_per_start"><![CDATA[Количество сообщенией, отправляемое из имейл очереди при каждом запуске]]></string>
     <string name="_adm_stg_cpt_option_sys_eq_send_per_start_to_recipient"><![CDATA[Количество сообщенией, отправляемое из имейл очереди одному и тому же получателю при каждом запуске]]></string>
 	<string name="_adm_stg_cpt_option_sys_oauth_key"><![CDATA[UNA-аккаунт - Key (ключ)]]></string>
@@ -1316,6 +1317,7 @@
     <string name="_adm_stg_cpt_option_sys_push_rest_api"><![CDATA[REST API Key]]></string>
     <string name="_adm_stg_cpt_option_sys_push_short_name"><![CDATA[Короткое имя (требуется только если у вас https сайт. Оно должно совпадать с поддоменом, введёным, в настройках пуш оповещений на OneSignal)]]></string>
     <string name="_adm_stg_cpt_option_sys_push_safari_id"><![CDATA[Apple Safari Web ID в натройках Web Push]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_queue_time"><![CDATA[Дата последнего запуска Push очереди]]></string>
     <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start"><![CDATA[Количество сообщенией, отправляемое из Push очереди при каждом запуске]]></string>
     <string name="_adm_stg_cpt_option_sys_push_queue_send_per_start_to_recipient"><![CDATA[Количество сообщенией, отправляемое из Push очереди одному и тому же получателю при каждом запуске]]></string>
 	<string name="_adm_stg_cpt_option_sys_twilio_gate_sid"><![CDATA[Account SID]]></string>