1st
This commit is contained in:
148
temp/main.go
Normal file
148
temp/main.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package main
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// "time"
|
||||
// "timeutil"
|
||||
// "tipper/model"
|
||||
// "web"
|
||||
// "web/api"
|
||||
// "web/kit/simplerouter"
|
||||
|
||||
// //"qx"
|
||||
// "qx"
|
||||
|
||||
// _ "github.com/go-sql-driver/mysql"
|
||||
// )
|
||||
|
||||
// const (
|
||||
// port = 7770
|
||||
// //baseDir = "/root/tipper"
|
||||
// //baseDir = ""
|
||||
// baseDir = "/home/ubuntu/tipper"
|
||||
// //baseDir = "/home/dima/work/go/src/tipper"
|
||||
// )
|
||||
|
||||
// var m *model.Model
|
||||
|
||||
// func main() {
|
||||
// //logger := log.New(os.Stdout, "", log.LstdFlags)
|
||||
|
||||
//db, err := qx.Open("mysql", "user:password@/tipper")
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// defer db.Close()
|
||||
|
||||
// m = model.New(db)
|
||||
|
||||
// publicAPI := api.NewAPI(api.Options{
|
||||
// //Private: false,
|
||||
// //ErrorMapping: fsmodel.ErrorMessages,
|
||||
// })
|
||||
|
||||
// publicAPI.Func("listStrategies", m.ListStrategies)
|
||||
// publicAPI.Func("listStrategyRatedChampStats", m.ListStrategyRatedChampStats)
|
||||
// publicAPI.Func("getStrategyRatedHistory", m.GetStrategyRatedHistory)
|
||||
|
||||
// router := simplerouter.New()
|
||||
// router.Handle("/", pageTips)
|
||||
// router.Handle("/best-strategies", pageStrategies)
|
||||
// router.Handle("/api", publicAPI.Index)
|
||||
|
||||
// app := web.NewApp(web.AppOptions{
|
||||
// Port: port,
|
||||
// Router: router,
|
||||
// BaseDir: baseDir,
|
||||
// TemplateDir: "templates",
|
||||
// StaticDirs: map[string]string{
|
||||
// "static": "static",
|
||||
// },
|
||||
// })
|
||||
|
||||
// app.Run()
|
||||
// }
|
||||
|
||||
// type TipView struct {
|
||||
// Time string
|
||||
// Name string
|
||||
// Champ string
|
||||
// Link string
|
||||
// Result string
|
||||
// Status model.TipStatus
|
||||
// StrategyID int64
|
||||
// }
|
||||
|
||||
// type DayTips struct {
|
||||
// Date string
|
||||
// Tips []TipView
|
||||
// }
|
||||
|
||||
// type PageTipsData struct {
|
||||
// Days []DayTips
|
||||
// }
|
||||
|
||||
// func pageTips(state *web.State, reply *web.Reply) (err error) {
|
||||
// tips, err := m.ListTips()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
|
||||
// var days []DayTips
|
||||
|
||||
// var currentDay int64
|
||||
// var dayTips DayTips
|
||||
|
||||
// for _, tip := range tips {
|
||||
// if tip.Status != model.Won && tip.Status != model.Lost {
|
||||
// continue
|
||||
// }
|
||||
|
||||
// tm := time.Unix(tip.TipTime, 0)
|
||||
|
||||
// tm, err = timeutil.FirstSecondInPeriod(tm.Format("2006-01-02"),
|
||||
// tm.Location(), "d")
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
|
||||
// day := tm.Unix()
|
||||
|
||||
// if day != currentDay {
|
||||
// if currentDay != 0 {
|
||||
// days = append(days, dayTips)
|
||||
// }
|
||||
|
||||
// dayTips = DayTips{
|
||||
// Date: tm.Format("Monday Jan 2, 2006"),
|
||||
// }
|
||||
|
||||
// currentDay = day
|
||||
// }
|
||||
|
||||
// dayTips.Tips = append(dayTips.Tips, TipView{
|
||||
// Time: tm.Format("15:04"),
|
||||
// Name: tip.MatchName,
|
||||
// Champ: tip.ChampName,
|
||||
// Link: fmt.Sprintf("https://www.flashscore.com/match/%s/#h2h;overall", tip.MatchID),
|
||||
// Result: tip.Result,
|
||||
// Status: tip.Status,
|
||||
// StrategyID: tip.StrategyID,
|
||||
// })
|
||||
|
||||
// }
|
||||
|
||||
// if currentDay != 0 {
|
||||
// days = append(days, dayTips)
|
||||
// }
|
||||
|
||||
// reply.Render("temp_tips", PageTipsData{
|
||||
// Days: days,
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
|
||||
// func pageStrategies(state *web.State, reply *web.Reply) (err error) {
|
||||
// reply.Render("temp_stats", nil)
|
||||
// return
|
||||
// }
|
||||
Reference in New Issue
Block a user