8bd3af4fcd77 — russes02 11 years ago
Adds domain1 flag; turns uat option into a flag
6 files changed, 13 insertions(+), 6 deletions(-)

M autocompare/main.go
M foundation.go
M loader.go
M multisites.go
M page.go
M scripts/retryfailures
M autocompare/main.go +3 -1
@@ 44,6 44,8 @@ func main() {
 	flag.Float64Var(&nrmsdThresh, "nrmsd-threshold", 0.1, "Threshold for the NRMSD")
 	flag.BoolVar(&keep, "k", false, "Keep failures (don't delete)")
 	profile := flag.String("prof", "", "Profile and write to this file")
+	uat := flag.Bool("uat", false, "Test against sites in UAT2")
+	useDomain1 := flag.Bool("domain1", false, "Use domain1 instead of the subdomain")
 	help := flag.Bool("h", false, "Print usage information")
 	flag.Usage = func() {
 		fmt.Printf("%s v%s\n", os.Args[0], version)

          
@@ 77,7 79,7 @@ func main() {
 	outputStream, logger := startLogger(pages)
 
 	// Read the input CSV
-	sites := NewSites(fname)
+	sites := NewSites(fname, *uat, *useDomain1)
 	comparitor := startComparisons(pageStream, outputStream, urlStream, sites.CheckLinks())
 	thresh := MAX_BUFFER / 2
 	warnThresh := int(math.Ceil(MAX_BUFFER / 1.5))

          
M foundation.go +1 -1
@@ 29,5 29,5 @@ func (s *FoundationSites) NextPage() Pag
 		state = PANIC
 		message = "MIGRATION broken"
 	}
-	return &BasePage{attempts: 0, subdomain: line[2], domain1: line[7], adID: line[6], state: state, message: message, id: line[1], baseURL: s.baseURL, uat: s.uat}
+	return &BasePage{attempts: 0, subdomain: line[2], domain1: line[7], adID: line[6], state: state, message: message, id: line[1], baseURL: s.baseURL, uat: s.uat, useDomain1: s.useDomain1}
 }

          
M loader.go +3 -3
@@ 18,12 18,13 @@ type SitesBase struct {
 	counts    map[string]int
 	baseURL   string
 	uat       bool
+	useDomain1 bool
 }
 
 func (s SitesBase) Processed() int                { return s.processed }
 func (s SitesBase) DroppedCounts() map[string]int { return s.counts }
 
-func NewSites(fileName string) Sites {
+func NewSites(fileName string, uat, useDomain1 bool) Sites {
 	// Read the first couple of lines twice; once to get a value from the second
 	// line without consuming it; the second to actually get the data
 	file, err := os.Open(fileName)

          
@@ 49,7 50,7 @@ func NewSites(fileName string) Sites {
 	reader.TrailingComma = true
 	reader.Read() // Get rid of header
 	var sites Sites
-	base := SitesBase{0, make(map[string]int), "", false}
+	base := SitesBase{0, make(map[string]int), "", uat, useDomain1}
 	switch source {
 	case "cdr":
 		base.baseURL = "http://%s.ybsites2.com%s"

          
@@ 57,7 58,6 @@ func NewSites(fileName string) Sites {
 		base.baseURL = "http://%s.ybsites.com%s"
 	case "uk":
 		base.baseURL = "http://%s.yellsites.co.uk%s"
-		base.uat = true
 	default:
 		log.Fatalf("Unknown source %s", source)
 	}

          
M multisites.go +1 -1
@@ 39,5 39,5 @@ func (s *MultiSites) NextPage() Page {
 		state = PANIC
 		message = "MIGRATION " + line[5]
 	}
-	return &BasePage{attempts: 0, subdomain: line[3], domain1: line[4], origPath: line[7], path: line[8], adID: line[6], origImg: "", copyImg: "", state: state, id: line[2], message: message, baseURL: s.baseURL, uat: s.uat}
+	return &BasePage{attempts: 0, subdomain: line[3], domain1: line[4], origPath: line[7], path: line[8], adID: line[6], origImg: "", copyImg: "", state: state, id: line[2], message: message, baseURL: s.baseURL, uat: s.uat, useDomain1: s.useDomain1}
 }

          
M page.go +4 -0
@@ 45,6 45,7 @@ type BasePage struct {
 	links     bool
 	baseURL   string
 	uat       bool
+	useDomain1      bool
 }
 
 func (p BasePage) Subdomain() string { return p.subdomain }

          
@@ 80,6 81,9 @@ func (p BasePage) Links() bool { return 
 func (p *BasePage) SetLinks(s bool) { p.links = s }
 
 func (p BasePage) OriginURL() string {
+	if p.useDomain1 && p.domain1 != "" {
+		return fmt.Sprintf("http://%s%s", p.domain1, p.origPath)
+	}
 	return fmt.Sprintf(p.baseURL, p.subdomain, p.origPath)
 }
 

          
M scripts/retryfailures +1 -0
@@ 7,5 7,6 @@ fi
 INPUT=$1
 DIR=`dirname $INPUT`
 
+head -n 1 $INPUT
 grep FAIL $DIR/out.csv.new | grep -v MIGRATION | awk -F, '{print $2}' | sort | uniq | grep -f - $INPUT
 #grep FAIL $1/out.csv | grep -v MIGRATION | grep -v NRMSD | awk -F, '{print $2}' | sort | uniq | grep -f - $1/page-report.csv