eklpsDb

package
v0.0.0-...-a55aa2f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dist

type Dist struct {
	Distance string
	Fl       string
	Sc       string
}

type Eklps

type Eklps struct {
	Dsn            string
	Conn           *sql.DB
	FilterMap      map[string]string
	ClassFilterMap map[string]string
}

func NewDb

func NewDb() (*Eklps, error)

func (*Eklps) AddFilters

func (eklps *Eklps) AddFilters(f string, q QueryWriter)

func (*Eklps) AddOrFilters

func (eklps *Eklps) AddOrFilters(f string, q QueryWriter)

func (*Eklps) BuildSql

func (eklps *Eklps) BuildSql(p Params) (bytes.Buffer, error)

* runs a query like

select r.id as RaceId, r.fullname as RaceName, date(substr(r.id, 1,8)) as RaceDate from races r left join race_conditions rc1 on r.id = rc1.id_races and r.distance = 1000 and

case rc1.class_eq
        when "=" then rc1.class = "E"
        when "<=" then ASCII(rc1.class) <= ASCII("E")
        when ">=" then ASCII(rc1.class) >= ASCII("E")
        else 1
end

left join race_conditions rc2 on r.id = rc2.id_races and r.distance = 1900 and

case rc2.class_eq
        when "=" then rc1.class = "K"
        when "<=" then ASCII(rc2.class) <= ASCII("K")
        when ">=" then ASCII(rc2.class) >= ASCII("K")
        else 1
end

left join race_conditions rc3 on r.id = rc3.id_races and r.distance = 1100 and

case rc3.class_eq
        when "=" then rc3.class = "C"
        when "<=" then ASCII(rc3.class) <= ASCII("C")
        when ">=" then ASCII(rc3.class) >= ASCII("C")
        else 1
end

left join race_conditions rc_void on r.id = rc_void.id_races and rc_void.class = "" where (r.age_conditions like "%2%" or (substr(r.age_conditions,1,1) <= "2" && substr(r.age_conditions,2,1) = "+")) and r.sex in ('f', 'all') and sc = 1 and case

when rc1.class is not null then 1
when rc2.class is not null then 1
when rc3.class is not null then 1
when rc_void.class is not null then 1
else 0

end

func (*Eklps) Connect

func (eklps *Eklps) Connect() error

func (*Eklps) GetRaces

func (eklps *Eklps) GetRaces(p Params) ([]Race, error)

func (*Eklps) GetSeason

func (eklps *Eklps) GetSeason() (int, error)

type Params

type Params struct {
	Age       int
	Sex       string
	Spec      string
	Distances []Dist
	Filters   []string
}

type QueryWriter

type QueryWriter interface {
	WriteString(string) (int, error)
}

type Race

type Race struct {
	RaceId    int
	RaceTitle string
	RaceDate  string
	RaceClass string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL