Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
koo04 committed May 28, 2024
1 parent 51b8fac commit 68da178
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@ func init() {
}

// setup the logger
f, err := os.OpenFile(settings.GetStringWithDefault("LOG.FILE", "/var/log/solbot/solbot.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err.Error())
os.Exit(1)
if settings.GetBool("LOG.CLI") {
handler := &customFormatter{hander: cli.New(os.Stdout)}
log.SetHandler(handler)
} else {
f, err := os.OpenFile(settings.GetStringWithDefault("LOG.FILE", "/var/log/solbot/solbot.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err.Error())
os.Exit(1)
}
log.SetHandler(jsn.New(f))
}
log.SetHandler(jsn.New(f))

if settings.GetBool("LOG.DEBUG") {
log.SetLevel(log.DebugLevel)
if settings.GetBool("LOG.CLI") {
handler := &customFormatter{hander: cli.New(os.Stdout)}
log.SetHandler(handler)
}
log.Debug("debug mode on")
}

Expand Down
4 changes: 2 additions & 2 deletions stores/attendance.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ func (s *AttendanceStore) GetCount(memberId string) (int, error) {
},
},
},
"-delta-",
bson.D{{Key: "$toString", Value: "$time_delta_hours"}},
"-overlap",
},
},
},
Expand All @@ -353,6 +352,7 @@ func (s *AttendanceStore) GetCount(memberId string) (int, error) {
},
},
},
{Key: "$match", Value: bson.D{{Key: "$not", Value: bson.D{{Key: "$regex", Value: "overlap"}}}}},
{Key: "names", Value: bson.D{{Key: "$push", Value: "$recordsWithPrev.current.name"}}},
{Key: "ids", Value: bson.D{{Key: "$push", Value: "$recordsWithPrev.current._id"}}},
{Key: "count", Value: bson.D{{Key: "$sum", Value: 1}}},
Expand Down

0 comments on commit 68da178

Please sign in to comment.