Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jira epic add time after #7161

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/plugins/jira/api/connection_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func testConnection(ctx context.Context, connection models.JiraConn) (*JiraTestC
return nil, errors.NotFound.New(fmt.Sprintf("Seems like an invalid Endpoint URL, please try %s", restUrl.String()))
}
if res.StatusCode == http.StatusUnauthorized {
return nil, errors.HttpStatus(http.StatusBadRequest).New("Error username/password")
return nil, errors.HttpStatus(http.StatusBadRequest).New("Error credential")
}

resBody := &models.JiraServerInfo{}
Expand Down Expand Up @@ -100,7 +100,7 @@ func testConnection(ctx context.Context, connection models.JiraConn) (*JiraTestC

errMsg := ""
if res.StatusCode == http.StatusUnauthorized {
return nil, errors.HttpStatus(http.StatusBadRequest).New("Please check your username/password")
return nil, errors.HttpStatus(http.StatusBadRequest).New("Please check your credential")
}

if res.StatusCode != http.StatusOK {
Expand Down
38 changes: 27 additions & 11 deletions backend/plugins/jira/tasks/epic_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ var CollectEpicsMeta = plugin.SubTaskMeta{
Name: "collectEpics",
EntryPoint: CollectEpics,
EnabledByDefault: true,
Description: "collect Jira epics from all boards, does not support either timeFilter or diffSync.",
Description: "collect Jira epics from all boards, supports both timeFilter and diffSync.",
DomainTypes: []string{plugin.DOMAIN_TYPE_TICKET, plugin.DOMAIN_TYPE_CROSS},
}

func CollectEpics(taskCtx plugin.SubTaskContext) errors.Error {
db := taskCtx.GetDal()
data := taskCtx.GetData().(*JiraTaskData)
logger := taskCtx.GetLogger()
batchSize := 100
if data.JiraServerInfo.DeploymentType == models.DeploymentServer && len(data.JiraServerInfo.VersionNumbers) == 3 && data.JiraServerInfo.VersionNumbers[0] <= 8 {
batchSize = 1
Expand All @@ -57,16 +58,31 @@ func CollectEpics(taskCtx plugin.SubTaskContext) errors.Error {
if err != nil {
return err
}
jql := "ORDER BY created ASC"
collector, err := api.NewApiCollector(api.ApiCollectorArgs{
RawDataSubTaskArgs: api.RawDataSubTaskArgs{
Ctx: taskCtx,
Params: JiraApiParams{
ConnectionId: data.Options.ConnectionId,
BoardId: data.Options.BoardId,
},
Table: RAW_EPIC_TABLE,

collectorWithState, err := api.NewStatefulApiCollector(api.RawDataSubTaskArgs{
Ctx: taskCtx,
Params: JiraApiParams{
ConnectionId: data.Options.ConnectionId,
BoardId: data.Options.BoardId,
},
Table: RAW_EPIC_TABLE,
})
if err != nil {
return err
}

loc, err := getTimeZone(taskCtx)
if err != nil {
logger.Info("failed to get timezone, err: %v", err)
} else {
logger.Info("got user's timezone: %v", loc.String())
}
jql := "ORDER BY created ASC"
if collectorWithState.Since != nil {
jql = "and " + buildJQL(*collectorWithState.Since, loc)
}

err = collectorWithState.InitCollector(api.ApiCollectorArgs{
ApiClient: data.ApiClient,
PageSize: 100,
Incremental: false,
Expand Down Expand Up @@ -107,7 +123,7 @@ func CollectEpics(taskCtx plugin.SubTaskContext) errors.Error {
if err != nil {
return err
}
return collector.Execute()
return collectorWithState.Execute()
}

func GetEpicKeysIterator(db dal.Dal, data *JiraTaskData, batchSize int) (api.Iterator, errors.Error) {
Expand Down
Loading