removed logging + improved dynamic result fetching
This commit is contained in:
parent
21c8f549f0
commit
a138928d63
6 changed files with 28 additions and 29 deletions
10
text.go
10
text.go
|
@ -90,15 +90,11 @@ func prefetchPage(query, safe, lang string, page int) {
|
|||
|
||||
func fetchTextResults(query, safe, lang string, page int) []TextSearchResult {
|
||||
var results []TextSearchResult
|
||||
var err error
|
||||
var duration time.Duration
|
||||
|
||||
for attempts := 0; attempts < len(textSearchEngines); attempts++ {
|
||||
engine := selectSearchEngine(textSearchEngines)
|
||||
for _, engine := range textSearchEngines {
|
||||
log.Printf("Using search engine: %s", engine.Name)
|
||||
|
||||
var searchResults []SearchResult
|
||||
searchResults, duration, err = engine.Func(query, safe, lang, page)
|
||||
searchResults, duration, err := engine.Func(query, safe, lang, page)
|
||||
updateEngineMetrics(&engine, duration, err == nil)
|
||||
if err != nil {
|
||||
log.Printf("Error performing search with %s: %v", engine.Name, err)
|
||||
|
@ -158,6 +154,7 @@ func displayResults(w http.ResponseWriter, results []TextSearchResult, query, la
|
|||
HasNextPage bool
|
||||
LanguageOptions []LanguageOption
|
||||
CurrentLang string
|
||||
NoResults bool
|
||||
}{
|
||||
Results: results,
|
||||
Query: query,
|
||||
|
@ -167,6 +164,7 @@ func displayResults(w http.ResponseWriter, results []TextSearchResult, query, la
|
|||
HasNextPage: hasNextPage,
|
||||
LanguageOptions: languageOptions,
|
||||
CurrentLang: lang,
|
||||
NoResults: len(results) == 0,
|
||||
}
|
||||
|
||||
err = tmpl.Execute(w, data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue