Beispiel #1
0
func main() {
	flag.Parse()
	for _, fname := range flag.Args() {
		rs := input.ReadCsos(fname)
		for _, j := range rs {
			fmt.Println(j)
		}
		fmt.Println()
	}
}
Beispiel #2
0
func FromCsoc(db sql.Db, oddily map[string]bool, vysledek input.Zavod) {
	csos := input.ReadCsos(vysledek.Fname)

	cs := make(map[types.Class]bool) // all classes

	for _, r := range csos {
		cs[r.Class] = true
	}

	rs := input.GetValid(csos, oddily, vysledek) // valid results

	nconts := make(map[types.Class]int) // number of classified runners
	for _, r := range rs {
		nconts[r.Class] += 1
	}

	//recount positions
	var prevp int
	var prevclass types.Class
	var prevrposition int
	for _, r := range rs {
		// different class
		if prevclass != r.Class {
			prevp = 0
			prevrposition = 0
		}
		// don't advance on ties
		p := prevp
		if r.Position != prevrposition {
			p++ // counting from 1
		}

		classrank := bodovani.SubClassRank(cs, r.Class)

		if r.FamilyGiven == "Gryc Jan" {
			log.Println(vysledek.Cislo, r.Class, classrank, p, nconts[r.Class])
		}

		b := bodovani.Score(classrank, p, nconts[r.Class], vysledek.Veteraniada)

		id := fmt.Sprintf("%s|%s", r.Regno.C, r.Regno.N)
		pts := strings.SplitN(r.FamilyGiven, " ", 2)
		family := pts[0]
		given := ""
		if len(pts) > 1 {
			given = pts[1]
		}

		db.Pridejvysledek(id, given, family, vysledek.Cislo, b, r.Class.A, r.Class.B)
		prevp = p
		prevclass = r.Class
		prevrposition = r.Position
	}
	fmt.Println()
}
func main() {
	flag.Parse()
	args := flag.Args()
	if len(args) != 3 {
		log.Fatal("args: oddily klasif_csos hlavni_csos")

	}

	oddily := input.Nacti_oddily(args[0])

	klasif := input.Zavod{}
	hlavni := input.Zavod{}

	csosklasif := input.ReadCsos(args[1])
	rsklasif := input.GetValid(csosklasif, oddily, klasif)

	csoshlavni := input.ReadCsos(args[2])
	rshlavni := input.GetValid(csoshlavni, oddily, hlavni)

	klasmap := map[types.Regno]bool{}
	for _, v := range rsklasif {
		klasmap[v.Regno] = true
	}

	fmt.Println("-")
	rs := []input.Csos{}
	for _, v := range rshlavni {
		_, found := klasmap[v.Regno]
		if found {
			rs = append(rs, v)
			l := []string{v.Class.String(),
				v.FamilyGiven,
				v.Regno.String(),
				v.License,
				v.Result}
			output.fprintfw(os.Stdout, l, []int{10, 25, 7, 1, 6})
		}
	}

}
func main() {
	flag.Parse()
	args := flag.Args()
	if len(args) != 3 {
		log.Fatal("args: oddily klasif_csos hlavni_csos")

	}

	oddily := input.Nacti_oddily(args[0])

	klasif := input.Zavod{}
	hlavni := input.Zavod{}

	csosklasif := input.ReadCsos(args[1])
	rsklasif := input.GetValid(csosklasif, oddily, klasif)

	csoshlavni := input.ReadCsos(args[2])
	rshlavni := input.GetValid(csoshlavni, oddily, hlavni)

	klasmap := map[types.Regno]bool{}
	for _, v := range rsklasif {
		klasmap[v.Regno] = true
	}

	cs := make(map[types.Class][]input.Csos)
	for _, v := range rshlavni {
		_, found := klasmap[v.Regno]
		if found { // klasifikovany
			c := v.Class
			cs[c] = append(cs[c], v)
		}
	}

	keys := make([]types.Class, 0)
	for k, _ := range cs {
		keys = append(keys, k)
	}

	types.ClassBy(func(c1, c2 *types.Class) bool {
		if c1.A == c2.A {
			if c1.B == c2.B {
				return c1.C < c2.C
			} else {
				return c1.B < c2.B
			}
		} else {
			return c1.A < c2.A
		}
		return false
	}).Sort(keys)

	fmt.Println("-")

	// bug, pokud poslední v A má stejný čas
	// jako první v B, budou na děleném místě

	for _, c := range keys {
		for _, v := range cs[c] {
			l := []string{fmt.Sprintf("%s%d", v.Class.A, v.Class.B), // drop .C
				v.FamilyGiven,
				v.Regno.String(),
				v.License,
				v.Result}
			output.Fprintfw(os.Stdout, l, []int{10, 25, 7, 1, 6})
		}
	}
}