feat(args): 1.add command args(date)
This commit is contained in:
parent
3d00fca1db
commit
a48cb45d05
16
main.go
16
main.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -21,6 +22,18 @@ type CountLiveAnchors struct {
|
||||||
CountMap string `xorm:"count_map"`
|
CountMap string `xorm:"count_map"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getArgsStartTime() time.Time {
|
||||||
|
date := flag.Arg(0)
|
||||||
|
if date != "" {
|
||||||
|
panic("please input date eg. '2020-11-30 16:29:17'")
|
||||||
|
}
|
||||||
|
start, err := time.ParseInLocation("2006-01-02 15:04:03", date, time.Local)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return start
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
mdb := database.NewStatisticsDB("mongodb://sg-board1.livenono.com:27018")
|
mdb := database.NewStatisticsDB("mongodb://sg-board1.livenono.com:27018")
|
||||||
|
|
||||||
|
@ -31,7 +44,8 @@ func main() {
|
||||||
|
|
||||||
cla := engine.Table("count_live_anchors")
|
cla := engine.Table("count_live_anchors")
|
||||||
|
|
||||||
start, err := time.ParseInLocation("2006-01-02 15:04:03", "2020-11-30 16:29:17", time.Local)
|
start := getArgsStartTime()
|
||||||
|
// start, err := time.ParseInLocation("2006-01-02 15:04:03", "2020-11-30 16:29:17", time.Local)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user