fixes for web endpoint
Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
parent
fed49ba3cb
commit
6480f27946
4 changed files with 12 additions and 8 deletions
|
|
@ -2,12 +2,13 @@ package activity
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitlab.com/whom/bingobot/internal/config"
|
||||
"gitlab.com/whom/bingobot/internal/state"
|
||||
"gitlab.com/whom/bingobot/internal/logging"
|
||||
"gitlab.com/whom/bingobot/internal/state"
|
||||
)
|
||||
|
||||
/* Activity module
|
||||
|
|
@ -18,7 +19,7 @@ const (
|
|||
ActivityModuleStartFail = "failed to start activity module"
|
||||
)
|
||||
|
||||
var currentUserActivity map[string][]state.UserActiveEvent
|
||||
var currentUserActivity = make(map[string][]state.UserActiveEvent)
|
||||
var userActivityLock sync.RWMutex
|
||||
|
||||
func Start() error {
|
||||
|
|
@ -38,6 +39,10 @@ func Start() error {
|
|||
user := emap[state.UserEventUserKey]
|
||||
etime := ev.Time()
|
||||
delta := time.Since(etime).Hours() / float64(24)
|
||||
logging.Debug(fmt.Sprintf(
|
||||
"processing UserActive event for %s", user,
|
||||
))
|
||||
|
||||
|
||||
if delta <= float64(config.Get().UserEventLifespanDays) {
|
||||
new := []state.UserActiveEvent{ev.(state.UserActiveEvent)}
|
||||
|
|
@ -46,6 +51,7 @@ func Start() error {
|
|||
if found {
|
||||
new = append(new, current...)
|
||||
}
|
||||
currentUserActivity[user] = new
|
||||
userActivityLock.Unlock()
|
||||
} else {
|
||||
logging.Warn("recieved expired useractive event")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue