lotto

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

FDJ-SDK-LOTTO

Static Badge Build status codecov Release Go Reference Go Report Card codebeat badge FOSSA Status

This package is a sdk of the lotto (FRANCAISE DES JEUX) and could get the full draws history. It get the draws history provided from any csv files and convert them in a standardized Draw format.

The project was promute to the new v1.0.0 release with a lot of break in change. This change follow my needs about a personnal project to process the lotto history.

Installation

Download fdj-sdk-lotto:

$ go get -u github.com/winning-number/fdj-sdk-lotto@latest
# go: downloading github.com/winning-number/fdj-sdk-lotto ...
# go: added github.com/winning-number/fdj-sdk-lotto ...

Usage

Read the godoc documentation

They are two way for use this sdk. You can get directly the history from the FRANCAISE DES JEUX or directly by providing a CSV file (in this case, you need to know all type of Draw)

  • From the FRANCAISE DES JEUX api
package main

import (
    "context"
    "github.com/winning-number/fdj-sdk-lotto"
)

func main() {
    var err error
    var driver lotto.API

    if driver, err = lotto.NewAPI(); err != nil {
        panic(err)
    }
    // get all by default
    if err = driver.LoadAPI(context.Background(), lotto.SourceAll()); err != nil {
        panic(err)
    }
    draws := driver.Draws(lotto.Filter{
        SuperLotto:   true
        GrandLotto:   true
        XmasLotto:    true
        ClassicLotto: true
        OldLotto:     true
    })
}
  • From your csv files
package main

import (
    "context"
    "github.com/winning-number/fdj-sdk-lotto"
)

func main() {
    var err error
    var driver lotto.API
    var file *os.File

    if file, err = os.Open("your_filepath.csv"); err != nil {
        panic(err)
    }
    defer file.Close()
    if driver, err = lotto.NewAPI(); err != nil {
        panic(err)
    }
    // get all by default
    if err = driver.LoadFile(file, lotto.GetSourceInfo(lotto.Loto201911)); err != nil {
        panic(err)
    }
    draws := driver.Draws(lotto.Filter{
        SuperLotto:   true
        GrandLotto:   true
        XmasLotto:    true
        ClassicLotto: true
        OldLotto:     true
    })
}

Type of DRAW

From the begin of the lotto, the rules are been updated any time. So, to exploit the full history, each version are interpreting like a global Draw type.

V0
  • Concern only the super lotto type before 2008 october. They was 6 balls between 1 and 49 included and one lucky ball between 1 and 49 included. All balls are added inside the global slice of ball inside the Draw type. Result is provinding in a pick order and number order.
  • Only one a joker+ picked by draw.
  • 7 Winners Rank by Draw.
V1
  • Concern only the classic lotto type before 2008 october. They was 6 balls between 1 and 49 included and one lucky ball between 1 and 49 included. All balls are added inside the global slice of ball inside the Draw type. Result is provinding in a pick order and number order.
  • They was one a joker+ and one joker number picked by draw.
  • 7 Winners Rank by Draw.
V2
  • Concern the classic lotto and the super lotto type between 2008 october and 2017 march. They was 5 balls between 1 and 49 included and one lucky ball between 1 and 9 included. these 5 balls are added inside the global slice of ball inside the Draw type and the lucky ball is added inside a LuckyBall field (int32).
  • Only one a joker+ picked by draw.
  • 6 Winners Rank by Draw.
V3
  • Concern the classic lotto, the super lotto, the grand lotto and the grand lotto (xmas) type between 2017 march and 2019 november. They was 5 balls between 1 and 49 included and one lucky ball between 1 and 9 included. these 5 balls are added inside the global slice of ball inside the Draw type and the lucky ball is added inside a LuckyBall field (int32). Result is provinding in a pick order and number order.
  • Only one a joker+ picked by draw.
  • 9 Winners Rank by Draw.
  • Add Winning number (any by draw depends of type of draw).
V4
  • Concern the classic lotto type from 2019 november. They was 5 balls between 1 and 49 included and one lucky ball between 1 and 9 included. these 5 balls are added inside the global slice of ball inside the Draw type and the lucky ball is added inside a LuckyBall field (int32). Result is provinding in a pick order and number order.
  • Only one a joker+ picked by draw.
  • 9 Winners Rank by Draw.
  • Add Winning number (any by draw depends of type of draw).
  • Add a Second Roll with 5 balls between 1 and 49 included (no lucky ball). Result is providing in only in a number order.
  • 4 Winners Rank for the second Roll

Contributing

 ❕  Use issues for everything

Read more informations with the CONTRIBUTING_GUIDE

For all changes, please update the CHANGELOG.txt file by replacing the existant content.

Thank you  🙏  👍 

Made with contrib.rocks.

License

GNU GPL v3

FOSSA Status

Documentation

Index

Constants

View Source
const (
	GrandLotoZipName       = "grandloto_201912.zip"
	GrandLotoNoelZipName   = "lotonoel_201703.zip"
	SuperLoto199605ZipName = "superloto_199605.zip"
	SuperLoto200810ZipName = "superloto_200810.zip"
	SuperLoto201703ZipName = "superloto_201703.zip"
	SuperLoto201907ZipName = "superloto_201907.zip"
	Loto197605ZipName      = "loto_197605.zip"
	Loto200810ZipName      = "loto_200810.zip"
	Loto201703ZipName      = "loto_201703.zip"
	Loto201902ZipName      = "loto_201902.zip"
	Loto201911ZipName      = "loto_201911.zip"
)

File names for the different lotto history from the FDJ API

View Source
const (
	APIBasePath = "https://media.fdj.fr/static/csv/loto"
)

Endpoint to contact the FDJ history service

Variables

View Source
var (
	ErrInvalidDrawType       = errors.New("draw type instance is invalid")
	ErrInvalidCSVType        = errors.New("csv type instance is invalid")
	ErrInvalidResponseHTTP   = errors.New("response http is invalid")
	ErrInvalidContextDecoder = errors.New("context decoder is invalid")
	ErrInvalidHTTPRequest    = errors.New("http request is invalid")
	ErrNoContext             = errors.New("context is nil")
	ErrDrawTypeKeyNotFound   = errors.New("draw type key not found in the context recorder")
)

Functions

This section is empty.

Types

type API

type API interface {
	// LoadAPI loads the history source from the FDJ archive
	LoadSource(ctx context.Context, source []SourceInfo) error
	// DownloadSource downloads the history source from the FDJ archive
	DownloadSource(ctx context.Context, path string, source []SourceInfo) error
	// SourceUpdatedAt returns the last update time of the history source
	SourceUpdatedAt(ctx context.Context, source SourceInfo) (time.Time, error)
	// LoadFile loads the history source from a file
	// source is used to know the type of the source
	// File must be a csv file with ';' separator
	LoadFile(path string, source SourceInfo) error
	// NDraws returns the number of draws
	NDraws(filter Filter) int64
	// Draws returns the draws depending on the filter
	Draws(filter Filter, order draw.OrderType) []draw.Draw
	// Reset resets the draws records
	Reset()
}

API is the interface to load the history source. It can load the history source from the FDJ archive or from a file. To get a default api instance, use NewAPI function.

func NewAPI

func NewAPI() API

NewAPI returns a new API

type Filter

type Filter struct {
	Day draw.Day

	SuperLotto   bool
	GrandLotto   bool
	XmasLotto    bool
	ClassicLotto bool

	OldLotto bool
}

Filter is the filter of draw. if day is empty, it will match all day. if old lotto is false, it will not match old lotto, otherwise it will match all. if super lotto is false, it will not match super lotto. if grand lotto is false, it will not match grand lotto. if xmas lotto is false, it will not match xmas lotto. if classic lotto is false, it will not match classic lotto. classic lotto is the default draw type (from november 2019).

func (Filter) Match

func (f Filter) Match(draw *draw.Draw) bool

Match returns true if the draw match the filter.

type Source

type Source int16

Source is the type of lotto history

const (
	GrandLoto Source = iota
	GrandLotoNoel
	SuperLoto199605
	SuperLoto200810
	SuperLoto201703
	SuperLoto201907
	Loto197605
	Loto200810
	Loto201703
	Loto201902
	// most recent lotto history
	Loto201911
)

Source constants for the different lotto history from the FDJ API

func SourceAll

func SourceAll() []Source

SourceAll returns all the sources available

type SourceInfo

type SourceInfo struct {
	APIZipName string
	Type       draw.Type
	Version    draw.Version
	Name       Source
}

SourceInfo contains the information about the source APIZipName is the name of the zip file containing the history from the FDJ api Type is the type of draw Version is the version of the draw for conversion Name is the name of the source

func GetSourceInfo

func GetSourceInfo(source Source) SourceInfo

GetSourceInfo returns the source info for the given source If the source is not found, it returns the most recent source info the most recent source info is Loto201911 (from november 2019)

func SourceInfoAll

func SourceInfoAll() []SourceInfo

SourceInfoAll returns all the source info

func (SourceInfo) URL

func (s SourceInfo) URL() string

URL returns the url to download the source

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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