challenge-sync-airbus: Do job
This commit is contained in:
parent
18b8f0f722
commit
3344e05e0d
6 changed files with 256 additions and 65 deletions
|
|
@ -6,10 +6,15 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func loadTS(tspath string) (timestamp map[AirbusUserId]time.Time, err error) {
|
||||
type TSValue struct {
|
||||
Time time.Time `json:"t"`
|
||||
Score int64 `json:"s"`
|
||||
}
|
||||
|
||||
func loadTS(tspath string) (timestamp map[string]*TSValue, err error) {
|
||||
var fd *os.File
|
||||
if _, err = os.Stat(tspath); os.IsNotExist(err) {
|
||||
timestamp = map[AirbusUserId]time.Time{}
|
||||
timestamp = map[string]*TSValue{}
|
||||
err = saveTS(tspath, timestamp)
|
||||
return
|
||||
} else if fd, err = os.Open(tspath); err != nil {
|
||||
|
|
@ -26,7 +31,7 @@ func loadTS(tspath string) (timestamp map[AirbusUserId]time.Time, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
func saveTS(tspath string, ts map[AirbusUserId]time.Time) error {
|
||||
func saveTS(tspath string, ts map[string]*TSValue) error {
|
||||
if fd, err := os.Create(tspath); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
|
|
|||
Reference in a new issue