diff --git a/configs/pipelines/sync_repo_issue_creators/process.sql b/configs/pipelines/sync_repo_issue_creators/process.sql index e61574beba4..245a52580f1 100644 --- a/configs/pipelines/sync_repo_issue_creators/process.sql +++ b/configs/pipelines/sync_repo_issue_creators/process.sql @@ -1,27 +1,27 @@ INSERT INTO mv_repo_issue_creators(repo_id, user_id, issues, first_issue_opened_at) WITH users_trigger_issue_events AS ( SELECT - /*+ READ_FROM_STORAGE(TIFLASH[github_events]) */ + /*+ READ_FROM_STORAGE(TIFLASH[ge]) */ repo_id, actor_id AS user_id - FROM github_events + FROM github_events ge WHERE type = 'IssuesEvent' AND created_at >= :from AND created_at < :to GROUP BY repo_id, actor_id ) SELECT - /*+ READ_FROM_STORAGE(TIFLASH[ge]) */ - ge.repo_id, - ge.actor_id AS user_id, + /*+ READ_FROM_STORAGE(TIFLASH[ge2]) */ + ge2.repo_id, + ge2.actor_id AS user_id, COUNT(DISTINCT number) AS issues, - MIN(ge.created_at) AS first_issue_opened_at -FROM github_events ge -JOIN users_trigger_issue_events u ON ge.repo_id = u.repo_id + MIN(ge2.created_at) AS first_issue_opened_at +FROM github_events ge2 +JOIN users_trigger_issue_events u ON ge2.repo_id = u.repo_id WHERE - ge.type = 'IssuesEvent' - AND ge.action = 'opened' - AND ge.actor_id = u.user_id -GROUP BY ge.repo_id, user_id + ge2.type = 'IssuesEvent' + AND ge2.action = 'opened' + AND ge2.actor_id = u.user_id +GROUP BY ge2.repo_id, user_id ON DUPLICATE KEY UPDATE issues = VALUES(issues), first_issue_opened_at = VALUES(first_issue_opened_at) diff --git a/configs/pipelines/sync_repo_pull_request_creators/process.sql b/configs/pipelines/sync_repo_pull_request_creators/process.sql index 12949336d51..208a4cca6ee 100644 --- a/configs/pipelines/sync_repo_pull_request_creators/process.sql +++ b/configs/pipelines/sync_repo_pull_request_creators/process.sql @@ -1,33 +1,33 @@ INSERT INTO mv_repo_pull_request_creators(repo_id, user_id, prs, first_pr_opened_at, first_pr_merged_at) WITH users_trigger_pr_events_recently AS ( SELECT - /*+ READ_FROM_STORAGE(TIFLASH[github_events]) */ + /*+ READ_FROM_STORAGE(TIFLASH[ge]) */ repo_id, actor_id AS user_id - FROM github_events + FROM github_events ge WHERE type = 'PullRequestEvent' AND created_at >= :from AND created_at < :to GROUP BY repo_id, actor_id ) SELECT - /*+ READ_FROM_STORAGE(TIFLASH[ge]) */ - ge.repo_id, + /*+ READ_FROM_STORAGE(TIFLASH[ge2]) */ + ge2.repo_id, CASE - WHEN ge.action = 'opened' THEN ge.actor_id - WHEN ge.action = 'closed' AND pr_merged = 1 THEN ge.creator_user_id + WHEN ge2.action = 'opened' THEN ge2.actor_id + WHEN ge2.action = 'closed' AND pr_merged = 1 THEN ge2.creator_user_id END AS user_id, COUNT(DISTINCT number) AS prs, - MIN(IF(ge.action = 'opened', ge.created_at, NULL)) AS first_pr_opened_at, - MIN(IF(ge.action = 'closed' AND pr_merged = 1, ge.created_at, NULL)) AS first_pr_merged_at -FROM github_events ge -JOIN users_trigger_pr_events_recently u ON ge.repo_id = u.repo_id + MIN(IF(ge2.action = 'opened', ge2.created_at, NULL)) AS first_pr_opened_at, + MIN(IF(ge2.action = 'closed' AND pr_merged = 1, ge2.created_at, NULL)) AS first_pr_merged_at +FROM github_events ge2 +JOIN users_trigger_pr_events_recently u ON ge2.repo_id = u.repo_id WHERE - ge.type = 'PullRequestEvent' + ge2.type = 'PullRequestEvent' AND ( - (ge.action = 'opened' AND ge.actor_id = u.user_id) - OR (ge.action = 'closed' AND pr_merged = 1 AND ge.creator_user_id = u.user_id) + (ge2.action = 'opened' AND ge2.actor_id = u.user_id) + OR (ge2.action = 'closed' AND pr_merged = 1 AND ge2.creator_user_id = u.user_id) ) -GROUP BY ge.repo_id, user_id +GROUP BY ge2.repo_id, user_id ON DUPLICATE KEY UPDATE prs = VALUES(prs), first_pr_opened_at = VALUES(first_pr_opened_at),