diff --git a/tools-public/toolpad/pages/OverviewPage/page.yml b/tools-public/toolpad/pages/OverviewPage/page.yml
index c7362db..bed55d1 100644
--- a/tools-public/toolpad/pages/OverviewPage/page.yml
+++ b/tools-public/toolpad/pages/OverviewPage/page.yml
@@ -405,6 +405,10 @@ spec:
name: text32
props:
value: Joy UI NPM KPIs
+ - component: Text
+ name: text34
+ props:
+ value: Team PR reviews activit
- component: PageColumn
name: pageColumn9
layout:
@@ -446,6 +450,17 @@ spec:
parameters: {}
content: View page
variant: text
+ - component: Button
+ name: button28
+ props:
+ content: View page
+ variant: text
+ onClick:
+ $$navigationAction:
+ page: muiTeamPullRequestReviews
+ parameters: {}
+ layout:
+ horizontalAlign: end
layout:
columnSize: 1
layout:
diff --git a/tools-public/toolpad/pages/muiTeamPullRequestReviews/page.yml b/tools-public/toolpad/pages/muiTeamPullRequestReviews/page.yml
new file mode 100644
index 0000000..9aa9bd4
--- /dev/null
+++ b/tools-public/toolpad/pages/muiTeamPullRequestReviews/page.yml
@@ -0,0 +1,86 @@
+# yaml-language-server: $schema=https://raw.githubusercontent.com/mui/mui-toolpad/v0.6.0/docs/schemas/v1/definitions.json#properties/Page
+
+apiVersion: v1
+kind: page
+spec:
+ title: muiTeamPullRequestReviews
+ display: shell
+ content:
+ - component: Text
+ name: text2
+ props:
+ value: TEAM PR REVIEWS ACITVITY
+ variant: h3
+ - component: Text
+ name: text1
+ props:
+ value:
+ $$jsExpression: '`This charts shows PR reviews per team data, in comparison with
+ a benchmark data (if provided). Use the repoId
&
+ benchmarkId
query params by specifying the OSS Insight id. For the
+ most commons used repositories, like mui/material-ui, mui/base-ui,
+ mui/pigment-css, vercel/next.js you can directly use the repository
+ name.`'
+ mode: markdown
+ - component: Text
+ name: text
+ layout:
+ columnSize: 1
+ props:
+ value:
+ $$jsExpression: "`MUI repo: ${page.parameters.repoId ??
+ 'mui/material-ui'}, Benchmark repo:
+ ${page.parameters.benchmarkId !== '' ?
+ page.parameters.benchmarkId : '(not specified)'}`"
+ mode: markdown
+ - component: Chart
+ name: muiPRReviewsPerTeam
+ layout:
+ columnSize: 1
+ props:
+ data:
+ - label: MUI repo data
+ kind: line
+ data:
+ $$jsExpression: getRepoDataQuery.data
+ color: '#2E96FF'
+ xKey: t_month
+ yKey: cnt
+ - label: Benchmark repo data
+ kind: line
+ data:
+ $$jsExpression: getBenchmarkRepoDataQuery.data
+ color: '#ff9800'
+ xKey: t_month
+ yKey: cnt
+ sx:
+ zIndex: 0
+ - component: codeComponent.Diff
+ name: diff
+ alias:
+ - gtOs1gW
+ parameters:
+ - name: repoId
+ value: '23083156'
+ - name: benchmarkId
+ value: ''
+ queries:
+ - name: getRepoDataQuery
+ mode: query
+ query:
+ function: functions.ts#getTeamPullRequestReviews
+ kind: local
+ parameters:
+ - name: repo
+ value:
+ $$jsExpression: page.parameters.repoId
+ - name: getBenchmarkRepoDataQuery
+ mode: query
+ query:
+ function: functions.ts#getTeamPullRequestReviews
+ kind: local
+ parameters:
+ - name: repo
+ value:
+ $$jsExpression: page.parameters.benchmarkId
diff --git a/tools-public/toolpad/resources/functions.ts b/tools-public/toolpad/resources/functions.ts
index 0617e4a..a310dfc 100644
--- a/tools-public/toolpad/resources/functions.ts
+++ b/tools-public/toolpad/resources/functions.ts
@@ -107,6 +107,62 @@ SELECT * FROM final_table
return data.data;
}
+export async function getTeamPullRequestReviews(repo: string = 'mui/material-ui') {
+ if (repo === '') {
+ return [];
+ }
+
+ const repoMap = {
+ 'mui/material-ui': 23083156,
+ 'mui/base-ui': 762289766,
+ 'mui/pigment-css': 715829513,
+ 'vercel/next.js': 70107786,
+ 'radix-ui/primitives': 273499522,
+ };
+
+ const repoParam = repoMap[repo] ?? repo;
+
+ const openQuery = `
+WITH maintainers as (
+ SELECT
+ DISTINCT ge.actor_login
+ FROM
+ github_events ge
+ WHERE
+ ge.repo_id = ${repoParam}
+ AND ge.type = 'PullRequestEvent'
+ /* maintainers are defined as the ones that are allowed to merge PRs */
+ AND ge.action = 'closed'
+ AND ge.pr_merged = 1
+ AND ge.created_at >= '2016-01-01'
+)
+SELECT
+ DATE_FORMAT(created_at, '%Y-%m-01') AS t_month,
+ COUNT(*) AS cnt
+FROM github_events ge
+WHERE
+ type = 'PullRequestReviewEvent' AND
+ action = 'created' AND
+ repo_id = ${repoParam} AND
+ actor_login in (SELECT actor_login FROM maintainers)
+ AND actor_login NOT LIKE 'oliviertassinari' AND actor_login NOT LIKE 'esp1lon' AND actor_login NOT LIKE 'mnajdova'
+ AND created_at >= '2020-01-01'
+GROUP BY 1 ORDER BY 1;
+ `;
+ const res = await fetch('https://api.ossinsight.io/q/playground', {
+ headers: {
+ 'content-type': 'application/json',
+ },
+ body: JSON.stringify({ sql: openQuery, type: 'repo', id: `${repoParam}` }),
+ method: 'POST',
+ });
+ if (res.status !== 200) {
+ throw new Error(`HTTP ${res.status}: ${(await res.text()).slice(0, 500)}`);
+ }
+ const data = await res.json();
+ return data.data;
+}
+
export async function queryCommitStatuses(repository: string) {
if (!process.env.GITHUB_TOKEN) {
throw new Error(`Env variable GITHUB_TOKEN not configured`);