Skip to content

Commit

Permalink
pipeline: force using tiflash for sync repo issue/pr creators pipeline (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini256 authored Dec 6, 2023
1 parent 5bcc5e0 commit a27d878
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
24 changes: 12 additions & 12 deletions configs/pipelines/sync_repo_issue_creators/process.sql
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
28 changes: 14 additions & 14 deletions configs/pipelines/sync_repo_pull_request_creators/process.sql
Original file line number Diff line number Diff line change
@@ -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),
Expand Down

0 comments on commit a27d878

Please sign in to comment.