Skip to content

Commit

Permalink
don't ignore srv as inactive, check date instead
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Sep 26, 2023
1 parent 339d0a9 commit e951f99
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/resources/server/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,23 @@ func (s *DB) GetServersToQuery(ctx context.Context, before time.Duration) ([]str
}

func (s *DB) GetAll(ctx context.Context) ([]All, error) {
list := []db.ServerModel{}
result, err := s.client.Server.
FindMany(db.Server.Active.Equals(true), db.Server.DeletedAt.IsNull()).
FindMany( /*db.Server.Active.Equals(true), */ db.Server.DeletedAt.IsNull()).
OrderBy(db.Server.UpdatedAt.Order(db.SortOrderAsc)).
With(db.Server.Ru.Fetch()).
Exec(ctx)

for idx := range result {
if time.Now().Sub(result[idx].UpdatedAt).Hours() <= 36 {
list = append(list, result[idx])
}
}

if err != nil {
return nil, err
}
return dbToAPISlice(result), err
return dbToAPISlice(list), err
}

func (s *DB) SetDeleted(ctx context.Context, ip string, at *time.Time) (*All, error) {
Expand Down

0 comments on commit e951f99

Please sign in to comment.