Skip to content

Commit

Permalink
solves #174
Browse files Browse the repository at this point in the history
  • Loading branch information
deinelieblings committed Aug 21, 2024
1 parent 33fc026 commit a653c87
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dao/update_ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ func UpdateTicker() {
quit := make(chan struct{})
EventStateFinishTicker()
EventStateClosedTicker()
UserActiveStateTicker()
go func() {
for {
select {
case <-ticker.C:
EventStateFinishTicker()
EventStateClosedTicker()
UserActiveStateTicker()
case <-quit:
ticker.Stop()
return
Expand Down Expand Up @@ -89,3 +91,24 @@ func EventStateClosedTicker() {

}
}

func UserActiveStateTicker() {
checkDate := time.Now().Unix() - 15768000
filter := bson.D{
{Key: "last_login_date", Value: bson.D{{Key: "$lte", Value: checkDate}}},
{Key: "active.status", Value: "confirmed"},
}
userList := []models.User{}
pipeline := models.UserPipeline(false).Match(filter).Pipe
if err := UserCollection.Aggregate(context.Background(), pipeline, &userList); err != nil {
log.Print(err)
}
for _, user := range userList {
update := bson.D{{Key: "status", Value: "rejected"}}
userFilter := bson.D{{Key: "_id", Value: user.Active.ID}}
if err := ActiveCollection.UpdateOne(context.Background(), userFilter, vmdb.UpdateSet(update), nil); err != nil {
log.Print(err)
}
}

}

0 comments on commit a653c87

Please sign in to comment.