Skip to content

Commit

Permalink
feat: updat desc
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 2d2f8b7 commit 13d0f81
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 86 deletions.
12 changes: 6 additions & 6 deletions configs/public_api/http_endpoints/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"name": "/repos/commits",
"name": "/repos/commits/time_distribution",
"description": "",
"method": "GET",
"endpoint": "/repos/pull_requests/monthly/loc_dump_AxJOjB",
"endpoint": "/repos/commits/time_distribution",
"data_source": {
"cluster_id": 1379661944642684098
},
Expand All @@ -26,7 +26,7 @@
"name": "from",
"type": "string",
"required": 0,
"default": "2000-01-01",
"default": "",
"description": ""
},
{
Expand All @@ -46,7 +46,7 @@
},
"tag": "Default",
"batch_operation": 0,
"sql_file": "sql/GET-repos-pull_requests-monthly-loc_dump_AxJOjB.sql",
"sql_file": "sql/GET-repos-commits-time_distribution.sql",
"type": "sql_endpoint",
"return_type": "json"
},
Expand Down Expand Up @@ -256,7 +256,7 @@
},
{
"name": "/repos/issues/open_to_first_resp",
"description": "Return the p0 - p100 number of the duration between issue opened to first response (comments / closed) (Unit: hours)",
"description": "Retrieve monthly response time percentiles (P0, P25, P50, P75, P100) for issues in a specific repository (Unit: Hours).",
"method": "GET",
"endpoint": "/repos/issues/open_to_first_responded",
"data_source": {
Expand Down Expand Up @@ -307,7 +307,7 @@
},
{
"name": "/repos/issues/open_to_closed",
"description": "Return the p0 - p100 number of the duration between issue opened to closed (Unit: hours)",
"description": "Retrieve monthly issue resolution time percentiles (P0, P25, P50, P75, P100) for a specific repository (Unit: Hours).",
"method": "GET",
"endpoint": "/repos/issues/open_to_closed",
"data_source": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
USE gharchive_dev;

SELECT
DAYOFWEEK(created_at) - 1 AS dayofweek,
HOUR(created_at) AS hour,
COUNT(1) AS pushes
FROM github_events
WHERE
repo_id IN (SELECT repo_id FROM github_repos WHERE repo_name = CONCAT(${owner}, '/', ${repo}) LIMIT 1)
AND type = 'PushEvent'
AND action = ''
AND
CASE
WHEN ${from} = '' THEN created_at >= DATE_SUB(NOW(), INTERVAL 1 YEAR)
ELSE (created_at >= ${from} AND created_at <= ${to})
END
GROUP BY dayofweek, hour
ORDER BY dayofweek, hour
;


Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,75 @@ with repo AS (
WHERE repo_name = CONCAT(${owner}, '/', ${repo})
LIMIT 1
), issue_with_closed_at as (
select
number, DATE_FORMAT(created_at, '%Y-%m-01') AS t_month, created_at as closed_at
from
github_events ge
where
type = 'IssuesEvent'
and action = 'closed'
and repo_id = (SELECT repo_id FROM repo)
AND created_at >= ${from}
AND created_at <= ${to}
select
number, DATE_FORMAT(created_at, '%Y-%m-01') AS t_month, created_at as closed_at
from
github_events ge
where
type = 'IssuesEvent'
and action = 'closed'
and repo_id = (SELECT repo_id FROM repo)
AND created_at >= ${from}
AND created_at <= ${to}
), issue_with_opened_at as (
select
number, created_at as opened_at
from
github_events ge
where
type = 'IssuesEvent'
and action = 'opened'
-- Exclude Bots
-- and actor_login not like '%bot%'
-- and actor_login not in (select login from blacklist_users bu)
and repo_id = (SELECT repo_id FROM repo)
AND created_at >= ${from}
AND created_at <= ${to}
select
number, created_at as opened_at
from
github_events ge
where
type = 'IssuesEvent'
and action = 'opened'
-- Exclude Bots
-- and actor_login not like '%bot%'
-- and actor_login not in (select login from blacklist_users bu)
and repo_id = (SELECT repo_id FROM repo)
AND created_at >= ${from}
AND created_at <= ${to}
), tdiff as (
select
DATE_FORMAT(t_month, '%Y-%m-01') AS t_month,
(UNIX_TIMESTAMP(iwc.closed_at) - UNIX_TIMESTAMP(iwo.opened_at)) as diff
from
issue_with_opened_at iwo
join issue_with_closed_at iwc on iwo.number = iwc.number and iwc.closed_at > iwo.opened_at
select
DATE_FORMAT(t_month, '%Y-%m-01') AS t_month,
(UNIX_TIMESTAMP(iwc.closed_at) - UNIX_TIMESTAMP(iwo.opened_at)) as diff
from
issue_with_opened_at iwo
join issue_with_closed_at iwc on iwo.number = iwc.number and iwc.closed_at > iwo.opened_at
), tdiff_with_rank as (
select
tdiff.t_month,
diff / 60 / 60 as diff,
ROW_NUMBER() over (partition by tdiff.t_month order by diff) as r,
count(*) over (partition by tdiff.t_month) as cnt,
first_value(diff / 60 / 60) over (partition by tdiff.t_month order by diff) as p0,
first_value(diff / 60 / 60) over (partition by tdiff.t_month order by diff desc) as p100
from tdiff
select
tdiff.t_month,
diff / 60 / 60 as diff,
ROW_NUMBER() over (partition by tdiff.t_month order by diff) as r,
count(*) over (partition by tdiff.t_month) as cnt,
first_value(diff / 60 / 60) over (partition by tdiff.t_month order by diff) as p0,
first_value(diff / 60 / 60) over (partition by tdiff.t_month order by diff desc) as p100
from tdiff
), tdiff_p25 as (
select
t_month, diff as p25
from
tdiff_with_rank tr
where
r = round(cnt * 0.25)
select
t_month, diff as p25
from
tdiff_with_rank tr
where
r = round(cnt * 0.25)
), tdiff_p50 as (
select
t_month, diff as p50
from
tdiff_with_rank tr
where
r = round(cnt * 0.5)
select
t_month, diff as p50
from
tdiff_with_rank tr
where
r = round(cnt * 0.5)
), tdiff_p75 as (
select
t_month, diff as p75
from
tdiff_with_rank tr
where
r = round(cnt * 0.75)
select
t_month, diff as p75
from
tdiff_with_rank tr
where
r = round(cnt * 0.75)
)
select
distinct tr.t_month AS event_month,
ROUND(p0, 2) AS p0,
ROUND(p25, 2) AS p25,
ROUND(p50, 2) AS p50,
ROUND(p75, 2) AS p75,
ROUND(p100, 2) AS p100
distinct tr.t_month AS event_month,
ROUND(p0, 2) AS p0,
ROUND(p25, 2) AS p25,
ROUND(p50, 2) AS p50,
ROUND(p75, 2) AS p75,
ROUND(p100, 2) AS p100
from tdiff_with_rank tr
left join tdiff_p25 p25 on tr.t_month = p25.t_month
left join tdiff_p50 p50 on tr.t_month = p50.t_month
Expand Down

This file was deleted.

0 comments on commit 13d0f81

Please sign in to comment.