Skip to content

Commit

Permalink
Ensure we're displaying in correct sorted order
Browse files Browse the repository at this point in the history
  • Loading branch information
cyx committed Jan 26, 2021
1 parent c9fa65b commit bdbb946
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"
"sort"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -64,12 +65,13 @@ Show the tenant logs.

for {
list, err = cli.api.Log.List(
management.Query(fmt.Sprintf("log_id:[* TO %s]", lastLogID)),
management.Query(fmt.Sprintf("log_id:[%s TO *]", lastLogID)),
management.Parameter("page", "0"),
management.Parameter("per_page", "1000"),
management.Parameter("per_page", "100"),
management.Parameter("sort", "date:-1"),
)
if err != nil {
cli.renderer.Errorf("Error: %v", err)
return
}

Expand Down Expand Up @@ -110,5 +112,9 @@ func dedupLogs(list []*management.Log, set map[string]struct{}) []*management.Lo
}
}

sort.Slice(res, func(i, j int) bool {
return res[i].GetDate().Before(res[j].GetDate())
})

return res
}

0 comments on commit bdbb946

Please sign in to comment.