-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lot of changes for export: wrapped export request
- Loading branch information
1 parent
19537ef
commit ea541ad
Showing
12 changed files
with
361 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,52 @@ | ||
package export | ||
|
||
type CSVParameters struct { | ||
Columns []string | ||
ColumnsLabel []string | ||
FormatColumnsData map[string]string | ||
Separator rune | ||
Limit int64 | ||
ChunkSize int64 | ||
Columns []Column `json:"columns"` | ||
Separator rune `json:"separator" default:","` | ||
Limit int64 `json:"limit"` | ||
} | ||
|
||
// Equals compares two CSVParameters | ||
func (p CSVParameters) Equals(Params CSVParameters) bool { | ||
if p.Separator != Params.Separator { | ||
return false | ||
} | ||
if p.Limit != Params.Limit { | ||
type Column struct { | ||
Name string `json:"name"` | ||
Label string `json:"label"` | ||
Format string `json:"format" default:""` | ||
} | ||
|
||
// Equals compares two Column | ||
func (p Column) Equals(column Column) bool { | ||
if p.Name != column.Name { | ||
return false | ||
} | ||
if p.ChunkSize != Params.ChunkSize { | ||
if p.Label != column.Label { | ||
return false | ||
} | ||
if len(p.Columns) != len(Params.Columns) { | ||
if p.Format != column.Format { | ||
return false | ||
} | ||
for i, column := range p.Columns { | ||
if column != Params.Columns[i] { | ||
return false | ||
} | ||
} | ||
if len(p.ColumnsLabel) != len(Params.ColumnsLabel) { | ||
return true | ||
} | ||
|
||
// Equals compares two CSVParameters | ||
func (p CSVParameters) Equals(params CSVParameters) bool { | ||
if p.Separator != params.Separator { | ||
return false | ||
} | ||
for i, columnLabel := range p.ColumnsLabel { | ||
if columnLabel != Params.ColumnsLabel[i] { | ||
return false | ||
} | ||
} | ||
if len(p.FormatColumnsData) != len(Params.FormatColumnsData) { | ||
if p.Limit != params.Limit { | ||
return false | ||
} | ||
for key, value := range p.FormatColumnsData { | ||
if value != Params.FormatColumnsData[key] { | ||
for i, column := range p.Columns { | ||
if !column.Equals(params.Columns[i]) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
// GetColumnsLabel returns the label of the columns | ||
func (p CSVParameters) GetColumnsLabel() []string { | ||
columns := make([]string, 0) | ||
for _, column := range p.Columns { | ||
columns = append(columns, column.Label) | ||
} | ||
return columns | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.