Skip to content

Commit 93f90d6

Browse files
authored
Merge branch 'main' into astandrik.2173
2 parents a7fc860 + 4bc3812 commit 93f90d6

File tree

2 files changed

+61
-21
lines changed

2 files changed

+61
-21
lines changed

.github/workflows/priority-score.yml

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Update CalculatedPriority field
1212
uses: actions/github-script@v7
1313
with:
14-
github-token: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }}
14+
github-token: ${{ secrets.YDBOT_TOKEN }}
1515
script: |
1616
const labelWeights = {
1717
"prio/high": 1000,
@@ -25,13 +25,15 @@ jobs:
2525
2626
const createdAt = new Date(issue.created_at);
2727
const daysOld = Math.floor((Date.now() - createdAt.getTime()) / (1000 * 60 * 60 * 24));
28-
2928
const finalScore = basePriority + daysOld;
3029
3130
const projectNumber = 24;
3231
const org = "ydb-platform";
32+
const issueNumber = issue.number;
33+
const repoName = context.repo.repo;
34+
const repoOwner = context.repo.owner;
3335
34-
const result = await github.graphql(`
36+
const projectQuery = await github.graphql(`
3537
query($org: String!, $number: Int!) {
3638
organization(login: $org) {
3739
projectV2(number: $number) {
@@ -44,35 +46,72 @@ jobs:
4446
}
4547
}
4648
}
47-
items(first: 100) {
48-
nodes {
49-
id
50-
content {
51-
... on Issue {
52-
id
53-
number
54-
}
55-
}
56-
}
57-
}
5849
}
5950
}
6051
}
6152
`, { org, number: projectNumber });
6253
63-
const project = result.organization.projectV2;
64-
const field = project.fields.nodes.find(f => f.name === "CalculatedPriority");
54+
const projectId = projectQuery.organization.projectV2.id;
55+
const field = projectQuery.organization.projectV2.fields.nodes.find(f => f.name === "CalculatedPriority");
6556
if (!field) {
6657
core.setFailed("Field 'CalculatedPriority' not found.");
6758
return;
6859
}
60+
const fieldId = field.id;
61+
62+
// Now paginate to find the matching item
63+
let item = null;
64+
let cursor = null;
65+
let hasNextPage = true;
66+
67+
while (hasNextPage && !item) {
68+
const response = await github.graphql(`
69+
query($org: String!, $number: Int!, $after: String) {
70+
organization(login: $org) {
71+
projectV2(number: $number) {
72+
items(first: 100, after: $after) {
73+
pageInfo {
74+
hasNextPage
75+
endCursor
76+
}
77+
nodes {
78+
id
79+
content {
80+
__typename
81+
... on Issue {
82+
number
83+
repository {
84+
name
85+
owner { login }
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
}
93+
}
94+
`, { org, number: projectNumber, after: cursor });
95+
96+
const items = response.organization.projectV2.items.nodes;
97+
98+
item = items.find(n =>
99+
n.content?.__typename === "Issue" &&
100+
n.content?.number === issueNumber &&
101+
n.content?.repository?.name === repoName &&
102+
n.content?.repository?.owner?.login === repoOwner
103+
);
104+
105+
hasNextPage = response.organization.projectV2.items.pageInfo.hasNextPage;
106+
cursor = response.organization.projectV2.items.pageInfo.endCursor;
107+
}
69108
70-
const item = project.items.nodes.find(n => n.content?.number === issue.number);
71109
if (!item) {
72-
console.log(`Issue #${issue.number} not found in project.`);
110+
console.log(`Issue #${issueNumber} not found in project (repo=${repoName}).`);
73111
return;
74112
}
75113
114+
// Update field
76115
await github.graphql(`
77116
mutation($input: UpdateProjectV2ItemFieldValueInput!) {
78117
updateProjectV2ItemFieldValue(input: $input) {
@@ -83,11 +122,11 @@ jobs:
83122
}
84123
`, {
85124
input: {
86-
projectId: project.id,
125+
projectId,
87126
itemId: item.id,
88-
fieldId: field.id,
127+
fieldId,
89128
value: { number: finalScore }
90129
}
91130
});
92131
93-
console.log(`Updated CalculatedPriority of issue #${issue.number} to ${finalScore}`);
132+
console.log(`Updated CalculatedPriority of issue #${issueNumber} to ${finalScore}`);

.github/workflows/quality.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
with:
27+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
2728
fetch-depth: 0
2829

2930
- name: Setup Node.js

0 commit comments

Comments
 (0)