Skip to content

Commit

Permalink
feat: add prs size history endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tidb-cloud-data-service[bot] authored Nov 25, 2023
1 parent 29eeb27 commit f014809
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 90 deletions.
6 changes: 3 additions & 3 deletions configs/public_api/http_endpoints/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"name": "/repos/pull_requests/open_to_mer_copy",
"name": "/repos/pull_requests/history/siz",
"description": "",
"method": "GET",
"endpoint": "/repos/pull_requests/open_to_merge_dump_uyQXjT",
"endpoint": "/repos/pull_requests/history/size",
"data_source": {
"cluster_id": 1379661944642684098
},
Expand Down Expand Up @@ -46,7 +46,7 @@
},
"tag": "Default",
"batch_operation": 0,
"sql_file": "sql/GET-repos-pull_requests-open_to_merge_dump_uyQXjT.sql",
"sql_file": "sql/GET-repos-pull_requests-history-size.sql",
"type": "sql_endpoint",
"return_type": "json"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
USE gharchive_dev;

SELECT
t_month AS event_month, xs, s, m, l, xl, xxl, all_size
FROM (
SELECT
t_month,
SUM(CASE WHEN (additions + deletions) < 10 THEN 1 ELSE 0 END) OVER(PARTITION BY t_month) AS xs,
SUM(CASE WHEN (additions + deletions) >= 10 AND (additions + deletions) < 30 THEN 1 ELSE 0 END) OVER(PARTITION BY t_month) AS s,
SUM(CASE WHEN (additions + deletions) >= 30 AND (additions + deletions) < 100 THEN 1 ELSE 0 END) OVER(PARTITION BY t_month) AS m,
SUM(CASE WHEN (additions + deletions) >= 100 AND (additions + deletions) < 500 THEN 1 ELSE 0 END) OVER(PARTITION BY t_month) AS l,
SUM(CASE WHEN (additions + deletions) >= 500 AND (additions + deletions) < 1000 THEN 1 ELSE 0 END) OVER(PARTITION BY t_month) AS xl,
SUM(CASE WHEN (additions + deletions) >= 1000 THEN 1 ELSE 0 END) OVER (PARTITION BY t_month) AS xxl,
COUNT(*) OVER (PARTITION BY t_month) AS all_size,
ROW_NUMBER() OVER (PARTITION BY t_month) AS row_num
FROM (
SELECT
DATE_FORMAT(created_at, '%Y-%m-01') as t_month,
additions,
deletions
FROM
github_events
WHERE
type = 'PullRequestEvent'
AND repo_id = (SELECT repo_id FROM github_repos WHERE repo_name = CONCAT(${owner}, '/', ${repo}) LIMIT 1)
AND action = 'opened'
AND created_at >= ${from}
AND created_at <= ${to}
) sub
) sub
WHERE row_num = 1
ORDER BY t_month
;

This file was deleted.

0 comments on commit f014809

Please sign in to comment.