refactor: build the issue report from loaded data

Issues loads the entries, rules, redirects, robots row and noindex
addresses, then issuesOf builds the report and blockedNoindex checks the
addresses against robots.txt, so the report's rules can be unit-tested
without a database. No behaviour change.
This commit is contained in:
2026-10-27 13:19:06 +01:00
parent 79567b3e18
commit 6d54fc7001
2 changed files with 51 additions and 27 deletions

View File

@@ -221,11 +221,17 @@ func (s *Service) BlockedNoindex(db *gorm.DB, content string, bots models.BotSwi
if err != nil {
return nil, err
}
return s.blockedNoindex(urls, content, bots), nil
}
// blockedNoindex lists the addresses of urls Googlebot may not fetch under
// the production file composed from content and bots.
func (s *Service) blockedNoindex(urls []string, content string, bots models.BotSwitches) []string {
var out []string
for _, u := range urls {
if !s.TestRobots(content, bots, "Googlebot", u).Allowed {
out = append(out, u)
}
}
return out, nil
return out
}