Skip to content

Commit

Permalink
fix: fixed to also check ActionType when validating the same date (#1191
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kakcy authored Aug 8, 2024
1 parent 238b390 commit 88c627b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/autoops/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,15 @@ func (s *AutoOpsService) UpdateAutoOpsRule(
for _, deleteClause := range req.DeleteClauseCommands {
delete(extractDateTimeClauses, deleteClause.Id)
}
checkTimes := make(map[int64]bool)
checkTimes := make(map[int64]autoopsproto.ActionType)
for _, c := range extractDateTimeClauses {
checkTimes[c.Time] = true
checkTimes[c.Time] = c.ActionType
}

// Check if there is a schedule with the same date and time.
for _, c := range req.AddDatetimeClauseCommands {
if checkTimes[c.DatetimeClause.Time] {
actionType, hasSameTime := checkTimes[c.DatetimeClause.Time]
if hasSameTime && actionType == c.DatetimeClause.ActionType {
dt, err := statusDatetimeClauseDuplicateTime.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(locale.InvalidArgumentError, "time"),
Expand All @@ -766,7 +767,8 @@ func (s *AutoOpsService) UpdateAutoOpsRule(
}
}
for _, c := range req.ChangeDatetimeClauseCommands {
if checkTimes[c.DatetimeClause.Time] {
actionType, hasSameTime := checkTimes[c.DatetimeClause.Time]
if hasSameTime && actionType == c.DatetimeClause.ActionType {
dt, err := statusDatetimeClauseDuplicateTime.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(locale.InvalidArgumentError, "time"),
Expand Down

0 comments on commit 88c627b

Please sign in to comment.