Skip to content

Commit

Permalink
updated CLI to use Eval.Count
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Nov 7, 2022
1 parent 1e7aca0 commit d3feff6
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions command/eval_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,28 +294,26 @@ func correctGrammar(word string, num int) string {

func (e *EvalDeleteCommand) handleDeleteByFilter(filterExpr string) (int, error) {

// TODO: querying for millions of evals is very expensive... can we add a count RPC?

// evals, _, err := e.client.Evaluations().List(&api.QueryOptions{
// Filter: filterExpr,
// })
// if err != nil {
// return 1, err
// }
// evals := []string{}

// If the user did not wish to bypass the confirmation step, ask this now
// and handle the response.
// if !e.yes && !e.deleteByArg {
// code, deleteEvals := e.askQuestion(fmt.Sprintf(
// "Are you sure you want to delete %v evals? [y/N]",
// len(evals)), "Cancelling eval deletion")
// e.Ui.Output("")

// if !deleteEvals {
// return code, nil
// }
// }
if !e.yes && !e.deleteByArg {

resp, _, err := e.client.Evaluations().Count(&api.QueryOptions{
Filter: filterExpr,
})
if err != nil {
return 1, err
}

code, deleteEvals := e.askQuestion(fmt.Sprintf(
"Are you sure you want to delete %d evals? [y/N]",
resp.Count), "Cancelling eval deletion")
e.Ui.Output("")

if !deleteEvals {
return code, nil
}
}

resp, _, err := e.client.Evaluations().DeleteOpts(&api.EvalDeleteRequest{
Filter: filterExpr,
Expand Down

0 comments on commit d3feff6

Please sign in to comment.