Skip to content

Commit

Permalink
feat(task): added GetCreated function
Browse files Browse the repository at this point in the history
  • Loading branch information
sandesvitor committed Oct 19, 2023
1 parent fe4294f commit 2c408a3
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 89 deletions.
11 changes: 10 additions & 1 deletion backend/plugins/opsgenie/tasks/incidents_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type (
Data json.RawMessage `json:"data"`
}
simplifiedRawIncident struct {
Id string `json:"id"`
Id string `json:"id"`
CreatedAt time.Time `json:"createdAt"`
}
)

Expand Down Expand Up @@ -93,6 +94,14 @@ func CollectIncidents(taskCtx plugin.SubTaskContext) errors.Error {
return rawResult.Data, err
},
},
GetCreated: func(item json.RawMessage) (time.Time, errors.Error) {
i := &simplifiedRawIncident{}
err := json.Unmarshal(item, i)
if err != nil {
return time.Time{}, errors.BadInput.Wrap(err, "failed to unmarshal opsgenie incidents")
}
return i.CreatedAt, nil
},
},
CollectUnfinishedDetails: &api.FinalizableApiCollectorDetailArgs{
BuildInputIterator: func() (api.Iterator, errors.Error) {
Expand Down
Loading

0 comments on commit 2c408a3

Please sign in to comment.