Skip to content

Commit 10b9131

Browse files
committed
update integration mapping
1 parent ef44ef2 commit 10b9131

File tree

3 files changed

+89
-25
lines changed

3 files changed

+89
-25
lines changed

docs/guides/all/track-ai-driven-pull-requests.md

Lines changed: 89 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Learn how to track and monitor AI-driven pull requests in your deve
77

88
The software engineering world has experienced a major breakthrough with AI coding agents such as GitHub Copilot, Claude, Devin, and others. Engineering teams are increasingly integrating these AI agents into their development workflows. This guide will help you create a comprehensive dashboard to bring visibility into what these AI agents are doing in your repositories.
99

10-
<img src="/img/guides/ai-driven-pr-dashboard-1.png" border="1px" width="100%" />
10+
<img src="/img/guides/ai-driven-pr-dashboard.png" border="1px" width="100%" />
1111

1212

1313
## Common use cases
@@ -79,36 +79,30 @@ When installing Port's GitHub app, the `Service` and `Pull request` blueprints a
7979
"type": "boolean",
8080
"title": "Draft",
8181
"description": "Whether the PR is in draft mode. Draft PR usually requires more attention."
82-
}
83-
```
84-
</details>
85-
86-
5. Add the following calculation property to the `calculationProperties` section:
87-
88-
<details>
89-
<summary><b>Work status calculation property (Click to expand)</b></summary>
90-
91-
```json showLineNumbers
82+
},
9283
"workStatus": {
84+
"type": "string",
9385
"title": "Coding agent status",
94-
"icon": "DefaultProperty",
9586
"description": "The most important status definition for a PR. \"Approved\" means needs to nudge reviewers/address comments, when \"Awaiting review\" requires urgent attention.",
96-
"calculation": "if .title | test(\"WIP\"; \"i\") then \"In Progress\" elif .properties.draft == true and (.relations.reviewers // [] | length) > 0 then \"Awaiting review\" elif .properties.draft == true and (.title | test(\"WIP\"; \"i\") | not) and (.relations.reviewers // [] | length) == 0 then \"Requested changes\" elif .properties.draft != true then \"Approved\" else \"Unknown\" end",
97-
"type": "string"
87+
"enum": [
88+
"In Progress",
89+
"Awaiting review",
90+
"Requested changes",
91+
"Approved",
92+
"Unknown"
93+
],
94+
"enumColors": {
95+
"In Progress": "yellow",
96+
"Awaiting review": "orange",
97+
"Requested changes": "turquoise",
98+
"Approved": "green",
99+
"Unknown": "lightGray"
100+
}
98101
}
99102
```
100103
</details>
101104

102-
:::tip Calculation explanation
103-
This calculation property automatically determines the work status of a PR based on:
104-
- **In Progress**: PR title contains "WIP" (work in progress)
105-
- **Awaiting review**: Draft PR with assigned reviewers
106-
- **Requested changes**: Draft PR without reviewers (likely needs changes)
107-
- **Approved**: Non-draft PR (ready for final review)
108-
- **Unknown**: Any other state
109-
:::
110-
111-
6. Add the following relation to the `relations` section:
105+
5. Add the following relation to the `relations` section:
112106

113107
<details>
114108
<summary><b>AI coding agent relation (Click to expand)</b></summary>
@@ -123,7 +117,77 @@ When installing Port's GitHub app, the `Service` and `Pull request` blueprints a
123117
```
124118
</details>
125119

126-
7. Click `Save` to update the blueprint.
120+
6. Click `Save` to update the blueprint.
121+
122+
123+
### Update GitHub integration configuration
124+
125+
Now we will update the GitHub integration configuration to ensure that the new properties added to the pull requests are correctly mapped.
126+
127+
1. Go to the [data sources](https://app.getport.io/settings/data-sources) page of your portal.
128+
2. Find your GitHub integration and click on it.
129+
3. Go to the `Mapping` tab.
130+
4. Add the following YAML block into the editor to map the pull request properties:
131+
132+
<details>
133+
<summary><b>Updated GitHub integration configuration (Click to expand)</b></summary>
134+
135+
```yaml showLineNumbers
136+
- kind: pull-request
137+
selector:
138+
query: "true"
139+
port:
140+
entity:
141+
mappings:
142+
identifier: .id|tostring
143+
title: .title
144+
blueprint: '"githubPullRequest"'
145+
properties:
146+
status: .status
147+
closedAt: .closed_at
148+
creata: .user.login
149+
updatedAt: .updated_at
150+
mergedAt: .merged_at
151+
createdAt: .created_at
152+
prNumber: .number
153+
link: .html_url
154+
labels: '[.labels[].name]'
155+
branch: .head.ref
156+
draft: .draft
157+
workStatus: >-
158+
if (.title | test("WIP"; "i")) then
159+
"In Progress"
160+
elif (.draft == true and ((.requested_reviewers // []) | length) >
161+
0) then
162+
"Awaiting review"
163+
elif (.draft == true and (.title | test("WIP"; "i") | not) and
164+
((.requested_reviewers // []) | length) == 0) then
165+
"Requested changes"
166+
elif (.draft != true) then
167+
"Approved"
168+
else
169+
"Unknown"
170+
end
171+
leadTimeHours: >-
172+
(.created_at as $createdAt | .merged_at as $mergedAt | ($createdAt
173+
| sub("\\..*Z$"; "Z") | strptime("%Y-%m-%dT%H:%M:%SZ") | mktime)
174+
as $createdTimestamp | ($mergedAt | if . == null then null else
175+
sub("\\..*Z$"; "Z") | strptime("%Y-%m-%dT%H:%M:%SZ") | mktime end)
176+
as $mergedTimestamp | if $mergedTimestamp == null then null else
177+
(((($mergedTimestamp - $createdTimestamp) / 3600) * 100 | floor) /
178+
100) end)
179+
relations:
180+
repository: .head.repo.name
181+
```
182+
:::tip Work Status JQ explanation
183+
This JQ determines the work status of a PR based on:
184+
- **In Progress**: PR title contains "WIP" (work in progress)
185+
- **Awaiting review**: Draft PR with assigned reviewers
186+
- **Requested changes**: Draft PR without reviewers (likely needs changes)
187+
- **Approved**: Non-draft PR (ready for final review)
188+
- **Unknown**: Any other state
189+
:::
190+
</details>
127191

128192

129193
## Set up automations
-177 KB
Binary file not shown.
201 KB
Loading

0 commit comments

Comments
 (0)