Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
40601df5
Commit
40601df5
authored
Oct 02, 2020
by
Dominik Hebeler
Browse files
fixed multipod adgoal
parent
b82053c3
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Console/Commands/RequestFetcher.php
View file @
40601df5
...
...
@@ -2,6 +2,7 @@
namespace
App\Console\Commands
;
use
Cache
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Redis
;
use
Log
;
...
...
@@ -84,7 +85,7 @@ class RequestFetcher extends Command
$status
=
curl_multi_exec
(
$this
->
multicurl
,
$active
);
$currentJobs
=
[];
if
(
!
$blocking
)
{
$elements
=
Redis
::
pipeline
(
function
(
$redis
){
$elements
=
Redis
::
pipeline
(
function
(
$redis
)
{
$redis
->
lrange
(
\
App\MetaGer
::
FETCHQUEUE_KEY
,
0
,
-
1
);
$redis
->
del
(
\
App\MetaGer
::
FETCHQUEUE_KEY
);
});
...
...
@@ -97,7 +98,7 @@ class RequestFetcher extends Command
}
if
(
sizeof
(
$currentJobs
)
>
0
)
{
foreach
(
$currentJobs
as
$currentJob
){
foreach
(
$currentJobs
as
$currentJob
)
{
$currentJob
=
json_decode
(
$currentJob
,
true
);
$ch
=
$this
->
getCurlHandle
(
$currentJob
);
if
(
curl_multi_add_handle
(
$this
->
multicurl
,
$ch
)
!==
0
)
{
...
...
@@ -170,6 +171,9 @@ class RequestFetcher extends Command
$pipe
->
set
(
$resulthash
,
$body
);
$pipe
->
expire
(
$resulthash
,
60
);
});
if
(
$cacheDurationMinutes
>
0
)
{
Cache
::
put
(
$resulthash
,
$body
,
$cacheDurationMinutes
*
60
);
}
}
finally
{
\
curl_multi_remove_handle
(
$mc
,
$info
[
"handle"
]);
}
...
...
@@ -180,7 +184,7 @@ class RequestFetcher extends Command
private
function
getCurlHandle
(
$job
)
{
$ch
=
curl_init
();
curl_setopt_array
(
$ch
,
array
(
CURLOPT_URL
=>
$job
[
"url"
],
CURLOPT_PRIVATE
=>
$job
[
"resulthash"
]
.
";"
.
$job
[
"cacheDuration"
],
...
...
app/Http/Controllers/MetaGerSearch.php
View file @
40601df5
...
...
@@ -187,6 +187,7 @@ class MetaGerSearch extends Controller
private
function
loadMoreJS
(
Request
$request
)
{
$request
->
request
->
add
([
"javascript"
=>
true
]);
# Create a MetaGer Instance with the supplied hash
$hash
=
$request
->
input
(
'loadMore'
,
''
);
...
...
app/MetaGer.php
View file @
40601df5
...
...
@@ -425,7 +425,7 @@ class MetaGer
}
}
}
else
{
$answer
=
Redis
::
get
(
$hash
);
$answer
=
Cache
::
get
(
$hash
);
}
if
(
$answer
===
null
)
{
return
false
;
...
...
app/Models/Searchengine.php
View file @
40601df5
...
...
@@ -3,9 +3,7 @@
namespace
App\Models
;
use
App\MetaGer
;
use
Cache
;
use
Illuminate\Support\Facades\Redis
;
use
Log
;
abstract
class
Searchengine
{
...
...
@@ -208,13 +206,6 @@ abstract class Searchengine
}
if
(
$body
!==
null
)
{
if
(
!
$this
->
cached
)
{
try
{
Cache
::
put
(
$this
->
hash
,
$body
,
$this
->
cacheDuration
*
60
);
}
catch
(
\
Exception
$e
)
{
Log
::
error
(
$e
->
getMessage
());
}
}
$this
->
loadResults
(
$body
);
$this
->
getNext
(
$metager
,
$body
);
$this
->
markNew
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment