keon94 commented on code in PR #4248:
URL:
https://github.com/apache/incubator-devlake/pull/4248#discussion_r1149966016
##########
backend/plugins/pagerduty/tasks/incidents_collector.go:
##########
@@ -18,37 +18,125 @@ limitations under the License.
package tasks
import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
- helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/tap"
+ "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/pagerduty/models"
+ "net/http"
+ "net/url"
+ "reflect"
+ "time"
)
const RAW_INCIDENTS_TABLE = "pagerduty_incidents"
var _ plugin.SubTaskEntryPoint = CollectIncidents
+type (
+ pagingInfo struct {
+ Limit *int `json:"limit"`
+ Offset *int `json:"offset"`
+ Total *int `json:"total"`
+ More *bool `json:"more"`
+ }
+ collectedIncidents struct {
+ pagingInfo
+ Incidents []json.RawMessage `json:"incidents"`
+ }
+
+ collectedIncident struct {
+ pagingInfo
+ Incident json.RawMessage `json:"incident"`
+ }
+ simplifiedRawIncident struct {
+ IncidentNumber int `json:"incident_number"`
+ CreatedAt time.Time `json:"created_at"`
+ }
+)
+
func CollectIncidents(taskCtx plugin.SubTaskContext) errors.Error {
data := taskCtx.GetData().(*PagerDutyTaskData)
- collector, err := tap.NewTapCollector(
- &tap.CollectorArgs[tap.SingerTapStream]{
- RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
- Ctx: taskCtx,
- Table: RAW_INCIDENTS_TABLE,
- Params: models.PagerDutyParams{
- Stream: models.IncidentStream,
- ConnectionId: data.Options.ConnectionId,
+ db := taskCtx.GetDal()
+ args := api.RawDataSubTaskArgs{
+ Ctx: taskCtx,
+ Params: PagerDutyParams{
+ ConnectionId: data.Options.ConnectionId,
+ },
+ Table: RAW_INCIDENTS_TABLE,
+ }
+ collector, err :=
api.NewStatefulApiCollectorForFinalizableEntity(api.FinalizableApiCollectorArgs{
+ RawDataSubTaskArgs: args,
+ ApiClient: data.Client,
+ TimeAfter: data.TimeAfter,
+ CollectNewRecordsByList: api.FinalizableApiCollectorListArgs{
+ PageSize: 1,
Review Comment:
Oh good catch, I was using this for testing, forgot to remove it lol
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]