Browse Source

Removed PassAll from ChangeFilter and fixed sort not being descending order.

thegreatrefactor
Gisle Aune 6 years ago
parent
commit
e194b6536e
  1. 2
      cmd/rpdata-server/main.go
  2. 2
      database/mongodb/changes.go
  3. 6
      models/change.go

2
cmd/rpdata-server/main.go

@ -57,7 +57,7 @@ func main() {
}
func logListedChanges(changes *services.ChangeService) {
sub := changes.Subscribe(context.Background(), models.ChangeFilter{PassAll: true})
sub := changes.Subscribe(context.Background(), models.ChangeFilter{})
for change := range sub {
log.Printf("Change: Author=%#+v Model=%#+v Op=%#+v", change.Author, change.Model, change.Op)

2
database/mongodb/changes.go

@ -47,7 +47,7 @@ func (r *changeRepository) List(ctx context.Context, filter models.ChangeFilter)
}
changes := make([]*models.Change, 0, initialSize)
err := r.changes.Find(query).All(&changes)
err := r.changes.Find(query).Sort("-date").Limit(limit).All(&changes)
if err != nil {
return nil, err
}

6
models/change.go

@ -104,10 +104,6 @@ func (change *Change) Objects() []interface{} {
}
func (change *Change) PassesFilter(filter ChangeFilter) bool {
if filter.PassAll {
return true
}
if filter.Author != nil && change.Author != *filter.Author {
return false
}
@ -172,6 +168,4 @@ type ChangeFilter struct {
EarliestDate *time.Time
Author *string
Limit *int
PassAll bool // DO NOT EXPOSE
}
Loading…
Cancel
Save