Skip to content

Commit

Permalink
fix: jira epic add time after (#7161) (#7162)
Browse files Browse the repository at this point in the history
* fix: jira epic add time after

* fix: description

Co-authored-by: abeizn <zikuan.an@merico.dev>
  • Loading branch information
github-actions[bot] and abeizn authored Mar 13, 2024
1 parent 89a8459 commit 0ac3fbc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
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

0 comments on commit 0ac3fbc

Please sign in to comment.