Skip to content

Commit

Permalink
fix: some gitlab subtasks are missing connection in left join clause
Browse files Browse the repository at this point in the history
  • Loading branch information
klesh committed Sep 4, 2024
1 parent dbd6c1c commit 797a819
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
11 changes: 4 additions & 7 deletions backend/plugins/gitlab/tasks/issue_label_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ func ConvertIssueLabels(subtaskCtx plugin.SubTaskContext) errors.Error {
SubtaskCommonArgs: subtaskCommonArgs,
Input: func(stateManager *api.SubtaskStateManager) (dal.Rows, errors.Error) {
clauses := []dal.Clause{
dal.Select("*"),
dal.From(&models.GitlabIssueLabel{}),
dal.Join(`left join _tool_gitlab_issues on
_tool_gitlab_issues.gitlab_id = _tool_gitlab_issue_labels.issue_id`),
dal.Where(`_tool_gitlab_issues.project_id = ?
and _tool_gitlab_issues.connection_id = ?`,
projectId, data.Options.ConnectionId),
dal.Select("l.*"),
dal.From("_tool_gitlab_issue_labels l"),
dal.Join(`LEFT JOIN _tool_gitlab_issues s ON s.gitlab_id = l.issue_id AND l.connection_id = s.connection_id`),
dal.Where(`s.project_id = ? AND s.connection_id = ?`, projectId, data.Options.ConnectionId),
dal.Orderby("issue_id ASC"),
}
if stateManager.IsIncremental() {
Expand Down
6 changes: 3 additions & 3 deletions backend/plugins/gitlab/tasks/job_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ var ConvertJobMeta = plugin.SubTaskMeta{
Dependencies: []*plugin.SubTaskMeta{&ConvertPipelineCommitMeta},
}

func ConvertJobs(taskCtx plugin.SubTaskContext) (err errors.Error) {
subtaskCommonArgs, data := CreateSubtaskCommonArgs(taskCtx, RAW_JOB_TABLE)
db := taskCtx.GetDal()
func ConvertJobs(subtaskCtx plugin.SubTaskContext) (err errors.Error) {
subtaskCommonArgs, data := CreateSubtaskCommonArgs(subtaskCtx, RAW_JOB_TABLE)
db := subtaskCtx.GetDal()
regexEnricher := data.RegexEnricher
subtaskCommonArgs.SubtaskConfig = regexEnricher.PlainMap()

Expand Down
4 changes: 2 additions & 2 deletions backend/plugins/gitlab/tasks/job_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ var ExtractApiJobsMeta = plugin.SubTaskMeta{
Dependencies: []*plugin.SubTaskMeta{&CollectApiJobsMeta},
}

func ExtractApiJobs(taskCtx plugin.SubTaskContext) errors.Error {
subtaskCommonArgs, data := CreateSubtaskCommonArgs(taskCtx, RAW_JOB_TABLE)
func ExtractApiJobs(subtaskCtx plugin.SubTaskContext) errors.Error {
subtaskCommonArgs, data := CreateSubtaskCommonArgs(subtaskCtx, RAW_JOB_TABLE)

extractor, err := api.NewStatefulApiExtractor(&api.StatefulApiExtractorArgs{
SubtaskCommonArgs: subtaskCommonArgs,
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/gitlab/tasks/mr_commit_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ConvertApiMergeRequestsCommits(subtaskCtx plugin.SubTaskContext) errors.Err
clauses := []dal.Clause{
dal.Select("c.*"),
dal.From("_tool_gitlab_mr_commits c"),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id`),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id AND c.connection_id = mr.connection_id`),
dal.Where(`mr.project_id = ? and mr.connection_id = ?`, data.Options.ProjectId, data.Options.ConnectionId),
}
if stateManager.IsIncremental() {
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/gitlab/tasks/mr_label_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ConvertMrLabels(subtaskCtx plugin.SubTaskContext) errors.Error {
clauses := []dal.Clause{
dal.Select("c.*"),
dal.From("_tool_gitlab_mr_labels c"),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id`),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id AND c.connection_id = mr.connection_id`),
dal.Where(`mr.project_id = ? and mr.connection_id = ?`, data.Options.ProjectId, data.Options.ConnectionId),
}
if stateManager.IsIncremental() {
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/gitlab/tasks/mr_note_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func ConvertMergeRequestNote(subtaskCtx plugin.SubTaskContext) errors.Error {
clauses := []dal.Clause{
dal.Select("c.*"),
dal.From("_tool_gitlab_mr_comments c"),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id`),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id AND c.connection_id = mr.connection_id`),
dal.Where(`mr.project_id = ? and mr.connection_id = ?`, data.Options.ProjectId, data.Options.ConnectionId),
}
if stateManager.IsIncremental() {
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/gitlab/tasks/mr_reviewer_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ConvertMrReviewers(subtaskCtx plugin.SubTaskContext) errors.Error {
clauses := []dal.Clause{
dal.Select("c.*"),
dal.From("_tool_gitlab_reviewers c"),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id`),
dal.Join(`LEFT JOIN _tool_gitlab_merge_requests mr ON mr.gitlab_id = c.merge_request_id AND c.connection_id = mr.connection_id`),
dal.Where(`mr.project_id = ? and mr.connection_id = ?`, data.Options.ProjectId, data.Options.ConnectionId),
}
if stateManager.IsIncremental() {
Expand Down

0 comments on commit 797a819

Please sign in to comment.