Skip to content

Commit

Permalink
fix: unordered columns of export
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jul 2, 2023
1 parent afb0e8d commit f42ee05
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions export/csv_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
mongo2 "go.mongodb.org/mongo-driver/mongo"
"os"
"path"
"sort"
"strconv"
"time"
)
Expand Down Expand Up @@ -261,9 +262,23 @@ func (svc *CsvService) getColumns(query bson.M, export interfaces.Export) (colum
// columns
columns = make([]string, 0, len(columnsSet))
for k := range columnsSet {
// skip task key
if k == constants.TaskKey {
continue
}

// skip _id
if k == "_id" {
continue
}

// append to columns
columns = append(columns, k)
}

// order columns
sort.Strings(columns)

return columns, nil
}

Expand Down

0 comments on commit f42ee05

Please sign in to comment.