update date filter to pass integers to graphql (#5087)
* update date filter to pass ints to graphql Signed-off-by: Priya Bibra <priya.bibra@airbnb.com> * revert go mod Signed-off-by: Priya Bibra <priya.bibra@airbnb.com> * sign Signed-off-by: Priya Bibra <priya.bibra@airbnb.com> * gofmt Signed-off-by: Priya Bibra <priya.bibra@airbnb.com> * revert go ver Signed-off-by: Priya Bibra <priya.bibra@airbnb.com> --------- Signed-off-by: Priya Bibra <priya.bibra@airbnb.com> Co-authored-by: Priya Bibra <priya.bibra@airbnb.com>
This commit is contained in:
parent
e9db75b884
commit
5ef8065704
|
@ -592,9 +592,20 @@ func (c *ChaosExperimentHandler) ListExperiment(projectID string, request model.
|
|||
|
||||
// Filtering based on date range (workflow's last updated time)
|
||||
if request.Filter.DateRange != nil {
|
||||
endDate := strconv.FormatInt(time.Now().UnixMilli(), 10)
|
||||
endDate := time.Now().UnixMilli()
|
||||
if request.Filter.DateRange.EndDate != nil {
|
||||
endDate = *request.Filter.DateRange.EndDate
|
||||
parsedEndDate, err := strconv.ParseInt(*request.Filter.DateRange.EndDate, 10, 64)
|
||||
if err != nil {
|
||||
return nil, errors.New("unable to parse end date")
|
||||
}
|
||||
|
||||
endDate = parsedEndDate
|
||||
}
|
||||
|
||||
// Note: StartDate cannot be passed in blank, must be "0"
|
||||
startDate, err := strconv.ParseInt(request.Filter.DateRange.StartDate, 10, 64)
|
||||
if err != nil {
|
||||
return nil, errors.New("unable to parse start date")
|
||||
}
|
||||
|
||||
filterWfDateStage := bson.D{
|
||||
|
@ -602,7 +613,7 @@ func (c *ChaosExperimentHandler) ListExperiment(projectID string, request model.
|
|||
"$match",
|
||||
bson.D{{"updated_at", bson.D{
|
||||
{"$lte", endDate},
|
||||
{"$gte", request.Filter.DateRange.StartDate},
|
||||
{"$gte", startDate},
|
||||
}}},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -419,16 +419,28 @@ func (c *ChaosExperimentRunHandler) ListExperimentRun(projectID string, request
|
|||
|
||||
// Filtering based on date range
|
||||
if request.Filter.DateRange != nil {
|
||||
endDate := strconv.FormatInt(time.Now().UnixMilli(), 10)
|
||||
endDate := time.Now().UnixMilli()
|
||||
if request.Filter.DateRange.EndDate != nil {
|
||||
endDate = *request.Filter.DateRange.EndDate
|
||||
parsedEndDate, err := strconv.ParseInt(*request.Filter.DateRange.EndDate, 10, 64)
|
||||
if err != nil {
|
||||
return nil, errors.New("unable to parse end date")
|
||||
}
|
||||
|
||||
endDate = parsedEndDate
|
||||
}
|
||||
|
||||
// Note: StartDate cannot be passed in blank, must be "0"
|
||||
startDate, err := strconv.ParseInt(request.Filter.DateRange.StartDate, 10, 64)
|
||||
if err != nil {
|
||||
return nil, errors.New("unable to parse start date")
|
||||
}
|
||||
|
||||
filterWfRunDateStage := bson.D{
|
||||
{
|
||||
"$match",
|
||||
bson.D{{"updated_at", bson.D{
|
||||
{"$lte", endDate},
|
||||
{"$gte", request.Filter.DateRange.StartDate},
|
||||
{"$gte", startDate},
|
||||
}}},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue