Skip to content

Commit

Permalink
Deployment from Data App
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 421e011 commit 8264cc8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 deletions.
52 changes: 37 additions & 15 deletions configs/public_api/http_endpoints/config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
[
{
"name": "/users/activities/monthly/event",
"description": "Retrieve the count of activities (pull requests, issues, issue comments, reviews, review comments, pushes) by a GitHub user in different repositories, grouped by repository and event period. (If `from` and `to` are not specified, the default period is the past year.)",
"name": "/users/contributions/monthly/typ",
"description": "Retrieve a summary of a GitHub user's monthly contributions (pull requests, issues, issue comments, reviews, review comments, pushes) categorized by contribution type in the specified time range. (If `from` and `to` are not specified, the default period is the past year.)",
"method": "GET",
"endpoint": "/users/activities/monthly/event_types",
"endpoint": "/users/contributions/monthly/types",
"data_source": {
"cluster_id": 1379661944642684098
},
"params": [],
"params": [
{
"name": "username",
"type": "string",
"required": 1,
"default": "",
"description": ""
},
{
"name": "from",
"type": "string",
"required": 0,
"default": "",
"description": ""
},
{
"name": "to",
"type": "string",
"required": 0,
"default": "2099-12-31",
"description": ""
}
],
"settings": {
"timeout": 30000,
"row_limit": 1000,
Expand All @@ -17,15 +39,15 @@
},
"tag": "Default",
"batch_operation": 0,
"sql_file": "sql/GET-users-activities-monthly-event_types.sql",
"sql_file": "sql/GET-users-contributions-monthly-types.sql",
"type": "sql_endpoint",
"return_type": "json"
},
{
"name": "/users/activities/repo_dist",
"name": "/users/contributions/hourly/repo",
"description": "Retrieve the count of activities (pull requests, issues, issue comments, reviews, review comments, pushes) by a GitHub user in different repositories, grouped by repository and event period. (If `from` and `to` are not specified, the default period is the past year.)",
"method": "GET",
"endpoint": "/users/activities/repo_distribution",
"endpoint": "/users/contributions/repo_distribution",
"data_source": {
"cluster_id": 1379661944642684098
},
Expand Down Expand Up @@ -61,15 +83,15 @@
},
"tag": "Default",
"batch_operation": 0,
"sql_file": "sql/GET-users-activities-repo_distribution.sql",
"sql_file": "sql/GET-users-contributions-repo_distribution.sql",
"type": "sql_endpoint",
"return_type": "json"
},
{
"name": "/users/activities/time_dist",
"description": "Retrieve a weekly and hourly distribution of a GitHub user's activities (pull requests, issues, issue comments, reviews, review comments, pushes) in the specified time range. (If `from` and `to` are not specified, the default period is the past year.)",
"name": "/users/contributions/time_dist",
"description": "Retrieve a weekly and hourly distribution of a GitHub user's contributions (pull requests, issues, issue comments, reviews, review comments, pushes) in the specified time range. (If `from` and `to` are not specified, the default period is the past year.)",
"method": "GET",
"endpoint": "/users/activities/time_distribution",
"endpoint": "/users/contributions/time_distribution",
"data_source": {
"cluster_id": 1379661944642684098
},
Expand Down Expand Up @@ -113,7 +135,7 @@
},
"tag": "Default",
"batch_operation": 0,
"sql_file": "sql/GET-users-activities-time_distribution.sql",
"sql_file": "sql/GET-users-contributions-time_distribution.sql",
"type": "sql_endpoint",
"return_type": "json"
},
Expand Down Expand Up @@ -1265,7 +1287,7 @@
},
{
"name": "Trending Repos",
"description": "Return trending repos.",
"description": "Retrieves information about trending GitHub repositories. It filters repositories based on their programming language and a specified time period",
"method": "GET",
"endpoint": "/trends/repos",
"data_source": {
Expand All @@ -1276,15 +1298,15 @@
"name": "language",
"type": "string",
"required": 0,
"default": "All",
"default": "",
"description": ""
},
{
"name": "period",
"type": "string",
"required": 0,
"default": "past_24_hours",
"description": ""
"description": "one of {past_24_hours, past_3_months, past_month, past_week}"
}
],
"settings": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
USE gharchive_dev;

SELECT
DATE_FORMAT(created_at, '%Y-%m-01') AS event_month,
CASE type
WHEN 'IssuesEvent' THEN 'issues'
WHEN 'IssueCommentEvent' THEN 'issue_comments'
Expand All @@ -9,20 +10,22 @@ SELECT
WHEN 'PullRequestReviewCommentEvent' THEN 'review_comments'
WHEN 'PushEvent' THEN 'pushes'
END AS contribution_type,
DATE_FORMAT(created_at, '%Y-%m-01') AS event_month,
COUNT(1) AS cnt
COUNT(*) AS activities
FROM github_events ge
WHERE
actor_id = 5086433 AND
(
actor_id = (SELECT id FROM github_users WHERE login = ${username} LIMIT 1)
AND (
(type = 'PullRequestEvent' AND action = 'opened') OR
(type = 'IssuesEvent' AND action = 'opened') OR
(type = 'IssueCommentEvent' AND action = 'created') OR
(type = 'PullRequestReviewEvent' AND action = 'created') OR
(type = 'PullRequestReviewCommentEvent' AND action = 'created') OR
(type = 'PushEvent' AND action = '')
)
AND (created_at BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW())
AND
CASE WHEN ${from} = '' THEN (ge.created_at BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW())
ELSE (ge.created_at >= ${from} AND ge.created_at <= ${to})
END
GROUP BY type, 2
ORDER BY 2
;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ USE gharchive_dev;
SELECT
gr.repo_id,
gr.repo_name,
COUNT(*) AS cnt,
COUNT(*) AS contributions,
DATE_FORMAT(ge.created_at, '%Y-%m-%d %k:00:00') AS event_period
FROM github_events ge
JOIN github_repos gr ON ge.repo_id = gr.repo_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ USE gharchive_dev;
SELECT
DAYOFWEEK(created_at) - 1 AS dayofweek,
HOUR(created_at) AS hour,
COUNT(*) AS activities
COUNT(*) AS contributions
FROM github_events ge
WHERE
actor_id = (SELECT id FROM github_users WHERE login = ${username} LIMIT 1)
Expand Down

0 comments on commit 8264cc8

Please sign in to comment.