class AuditLink extends Base
{
protected $_batchSize = 500;
- protected static $minTimeBetweenRequests = 10;
+ protected $_url = null;
+ protected static $minTimeBetweenRequests = 2;
/**
* Create a new job instance.
*/
- public function __construct($batchSize = 500)
+ public function __construct($batchSize = 500, $url = null)
{
$this->_batchSize = $batchSize;
+ $this->_url = $url;
}
public function handle()
{
- $urls = [];
- foreach (FluidbookAuditLink::orderBy('updated_at', 'asc')->get() as $link) {
- if (!isset($urls[$link->url])) {
- $urls[$link->url] = $link->http_code ?? 0;
+ if (null == $this->_url) {
+ $urls = [];
+ foreach (FluidbookAuditLink::orderBy('updated_at', 'asc')->get() as $link) {
+ if (!isset($urls[$link->url])) {
+ $urls[$link->url] = $link->http_code ?? 0;
+ }
}
+ $urls = array_slice($urls, 0, $this->_batchSize, true);
+ ArrayUtil::shuffle($urls);
+ } else {
+ $urls = [$this->_url => 200];
}
- $urls = array_slice($urls, 0, $this->_batchSize, true);
- ArrayUtil::shuffle($urls);
+
HTTP::setCookieFile(Files::mkdir(protected_path('fluidbookpublication/linkaudit')) . 'cookies.txt');
} else {
$res = HTTP::getResponseCode($url, 10, 'http://paris.cubedesigners.com:8191/v1');
}
+ Log::info('Tested ' . $url . ': ' . $res['http_code']);
if ($res['http_code'] != $previousCode) {
$res['code_date'] = new \DateTime();