Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
6ba2274c
Commit
6ba2274c
authored
4 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
fixed adgoal when no public/private key available
parent
c3d3a60c
Branches
Branches containing commit
No related tags found
2 merge requests
!1712
Development
,
!1696
Development
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/Http/Controllers/MetaGerSearch.php
+2
-5
2 additions, 5 deletions
app/Http/Controllers/MetaGerSearch.php
app/MetaGer.php
+35
-6
35 additions, 6 deletions
app/MetaGer.php
with
37 additions
and
11 deletions
app/Http/Controllers/MetaGerSearch.php
+
2
−
5
View file @
6ba2274c
...
...
@@ -97,10 +97,7 @@ class MetaGerSearch extends Controller
}
# Ergebnisse der Suchmaschinen kombinieren:
$metager
->
prepareResults
();
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
]
=
microtime
(
true
)
-
$time
;
}
$metager
->
prepareResults
(
$timings
);
$finished
=
true
;
foreach
(
$metager
->
getEngines
()
as
$engine
)
{
...
...
@@ -213,7 +210,7 @@ class MetaGerSearch extends Controller
$metager
->
setApiAuthorized
(
$mg
[
"apiAuthorized"
]);
$metager
->
setAdgoalLoaded
(
$adgoal
[
"loaded"
]);
$metager
->
setAdgoalHash
(
$adgoal
[
"adgoalHash"
]);
$metager
->
parseFormData
(
$request
);
# Nach Spezialsuchen überprüfen:
$metager
->
checkSpecialSearches
(
$request
);
...
...
This diff is collapsed.
Click to expand it.
app/MetaGer.php
+
35
−
6
View file @
6ba2274c
...
...
@@ -252,11 +252,14 @@ class MetaGer
}
}
public
function
prepareResults
()
public
function
prepareResults
(
&
$timings
=
null
)
{
$engines
=
$this
->
engines
;
// combine
$this
->
combineResults
(
$engines
);
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"combined results"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
// misc (WiP)
if
(
$this
->
fokus
==
"nachrichten"
)
{
$this
->
results
=
array_filter
(
$this
->
results
,
function
(
$v
,
$k
)
{
...
...
@@ -276,7 +279,9 @@ class MetaGer
return
(
$a
->
getRank
()
<
$b
->
getRank
())
?
1
:
-
1
;
});
}
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"sorted results"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
# Validate Results
$newResults
=
[];
foreach
(
$this
->
results
as
$result
)
{
...
...
@@ -285,7 +290,9 @@ class MetaGer
}
}
$this
->
results
=
$newResults
;
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"validated results"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
# Validate Advertisements
$newResults
=
[];
foreach
(
$this
->
ads
as
$ad
)
{
...
...
@@ -298,7 +305,9 @@ class MetaGer
$newResults
[]
=
$ad
;
}
$this
->
ads
=
$newResults
;
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"validated ads"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
#Adgoal Implementation
if
(
empty
(
$this
->
adgoalLoaded
))
{
$this
->
adgoalLoaded
=
false
;
...
...
@@ -312,11 +321,20 @@ class MetaGer
}
}
$this
->
adgoalHash
=
$this
->
startAdgoal
(
$this
->
results
);
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"started adgoal"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
if
(
!
$this
->
javascript
)
{
$this
->
adgoalLoaded
=
$this
->
parseAdgoal
(
$this
->
results
,
$this
->
adgoalHash
,
true
);
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"parsed adgoal"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
else
{
$this
->
adgoalLoaded
=
$this
->
parseAdgoal
(
$this
->
results
,
$this
->
adgoalHash
,
false
);
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"parsed adgoal"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
}
else
{
$this
->
adgoalLoaded
=
true
;
...
...
@@ -325,6 +343,9 @@ class MetaGer
# Human Verification
$this
->
humanVerification
(
$this
->
results
);
$this
->
humanVerification
(
$this
->
ads
);
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"human verification"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
$counter
=
0
;
$firstRank
=
0
;
...
...
@@ -345,6 +366,9 @@ class MetaGer
'engines'
=>
$this
->
next
,
];
Cache
::
put
(
$this
->
getSearchUid
(),
serialize
(
$this
->
next
),
60
*
60
);
if
(
!
empty
(
$timings
)){
$timings
[
"prepareResults"
][
"filled cache"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
else
{
$this
->
next
=
[];
}
...
...
@@ -375,7 +399,7 @@ class MetaGer
$publicKey
=
getenv
(
'adgoal_public'
);
$privateKey
=
getenv
(
'adgoal_private'
);
if
(
$publicKey
===
false
)
{
return
null
;
return
true
;
}
$tldList
=
""
;
foreach
(
$results
as
$result
)
{
...
...
@@ -393,7 +417,7 @@ class MetaGer
# Hashwert
$hash
=
md5
(
"meta"
.
$publicKey
.
$tldList
.
"GER"
);
# Query
$query
=
$this
->
q
;
...
...
@@ -422,6 +446,11 @@ class MetaGer
$startTime
=
microtime
(
true
);
$answer
=
null
;
# Hash is true if Adgoal request wasn't started in the first place
if
(
$hash
===
true
){
return
true
;
}
if
(
$waitForResult
)
{
while
(
microtime
(
true
)
-
$startTime
<
5
)
{
$answer
=
Redis
::
get
(
$hash
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment