Skip to content

Commit dcaaf26

Browse files
Add monthly mode for slipped sprint items. (#399)
* Only update 5 days after sprint closing * Create workflow to process all open items Fixes #395 Add a mode where all labeled open issues or pull requests are processed. This runs once on the morning after the 5th of the month to update any items slipped in the previous sprint. Only move items to the "future" sprint after the 5th of the month. Create workflow to run the new mode once a month. * Apply suggestions from code review * use a single yaml file. * Update .github/workflows/quest-bulk.yml Co-authored-by: David Pine <[email protected]> --------- Co-authored-by: David Pine <[email protected]>
1 parent f314d8b commit dcaaf26

File tree

7 files changed

+40
-16
lines changed

7 files changed

+40
-16
lines changed

.github/workflows/quest-bulk.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: "bulk quest import"
22
on:
33
schedule:
44
- cron: '0 10 * * *' # UTC time, that's 5:00 am EST, 2:00 am PST.
5+
- cron: '0 9 6 * *' # This is the morning of the 6th.
6+
57
workflow_dispatch:
68
inputs:
79
reason:
@@ -49,4 +51,4 @@ jobs:
4951
org: ${{ github.repository_owner }}
5052
repo: ${{ github.repository }}
5153
issue: '-1'
52-
duration: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.duration || 5 }}
54+
duration: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.duration || github.event.schedule == '0 9 6 * *' && -1 || 5 }}

DotNet.DocsTools/GitHubObjects/QuestIssue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static GraphQLPacket GetQueryPacket(QuestIssueOrPullRequestVariables vari
2828
{
2929
["organization"] = variables.Organization,
3030
["repository"] = variables.Repository,
31+
["states"] = variables.states.Any() ? variables.states : ["OPEN", "CLOSED"],
3132
["questlabels"] = new string[]
3233
{
3334
variables.importTriggerLabelText ?? throw new ArgumentException("The import trigger label can't be null"),

DotNet.DocsTools/GitHubObjects/QuestIssueOrPullRequest.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ namespace DotNet.DocsTools.GitHubObjects;
1313
/// </remarks>
1414
/// <param name="Organization">the GH org</param>
1515
/// <param name="Repository">The GH repository</param>
16+
/// <param name="states">The array of requested states</param>
1617
/// <param name="issueNumber">The issue number. Only used for scalar queries</param>
1718
/// <param name="importTriggerLabelText">The trigger label text. Only used for enumerations</param>
1819
/// <param name="importedLabelText">The imported label text. Only used for enumerations.</param>
1920
public readonly record struct QuestIssueOrPullRequestVariables(
2021
string Organization,
21-
string Repository,
22+
string Repository,
23+
string[] states,
2224
int? issueNumber = null,
2325
string? importTriggerLabelText = null,
2426
string? importedLabelText = null);
@@ -127,7 +129,7 @@ ... on User {
127129
""";
128130

129131
protected const string EnumerateQuestIssuesQueryText = """
130-
query FindUpdatedIssues($organization: String!, $repository: String!, $questlabels: [String!], $cursor: String) {
132+
query FindUpdatedIssues($organization: String!, $repository: String!, $states: [IssueState!], $questlabels: [String!], $cursor: String) {
131133
repository(owner: $organization, name: $repository) {
132134
issues(
133135
""" + EnumerationQueryBody +
@@ -150,7 +152,7 @@ ... on PullRequest {
150152
""";
151153

152154
protected const string EnumerateQuestPullRequestQueryText = """
153-
query FindUpdatedPullRequests($organization: String!, $repository: String!, $questlabels: [String!], $cursor: String) {
155+
query FindUpdatedPullRequests($organization: String!, $repository: String!, $states: [PullRequestState!], $questlabels: [String!], $cursor: String) {
154156
repository(owner: $organization, name: $repository) {
155157
pullRequests(
156158
""" + EnumerationQueryBody +
@@ -162,6 +164,7 @@ query FindUpdatedPullRequests($organization: String!, $repository: String!, $que
162164
""";
163165

164166
private const string EnumerationQueryBody = """
167+
states: $states
165168
first: 25
166169
after: $cursor
167170
labels: $questlabels

DotNet.DocsTools/GitHubObjects/QuestPullRequest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static GraphQLPacket GetQueryPacket(QuestIssueOrPullRequestVariables vari
2828
{
2929
["organization"] = variables.Organization,
3030
["repository"] = variables.Repository,
31+
["states"] = variables.states.Any() ? variables.states : ["OPEN", "CLOSED", "MERGED"],
3132
["questlabels"] = new string[]
3233
{
3334
variables.importTriggerLabelText ?? throw new ArgumentException("The import trigger label can't be null"),

DotNet.DocsTools/GitHubObjects/StoryPointSize.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ public bool IsPastIteration
102102
{
103103
get
104104
{
105-
var currentYear = int.Parse(DateTime.Now.ToString("yyyy"));
106-
var currentMonth = MonthOrdinal(DateTime.Now.ToString("MMM"));
105+
var targetDate = DateTime.Now.AddDays(-5);
106+
var targetYear = int.Parse(targetDate.ToString("yyyy"));
107+
var targetMonth = MonthOrdinal(targetDate.ToString("MMM"));
107108

108-
if (CalendarYear < currentYear)
109+
if (CalendarYear < targetYear)
109110
{
110111
return true;
111-
} else if (CalendarYear == currentYear)
112+
} else if (CalendarYear == targetYear)
112113
{
113-
return MonthOrdinal(Month) < currentMonth;
114+
return MonthOrdinal(Month) < targetMonth;
114115
}
115116
return false;
116117
}

actions/sequester/ImportIssues/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private static async Task<int> Main(
2121
string org,
2222
string repo,
2323
int? issue = null,
24-
int? duration = 5,
24+
int? duration = null,
2525
string? questConfigPath = null,
2626
string? branch = null)
2727
{
@@ -40,6 +40,8 @@ private static async Task<int> Main(
4040

4141
Console.WriteLine(singleIssue
4242
? $"Processing single issue {issue!.Value}: https://github.com/{org}/{repo}/issues/{issue.Value}"
43+
: (duration is not null) && (duration != -1)
44+
? $"Processing all issues updated in the last {duration} days: {org}/{repo}"
4345
: $"Processing all open issues: {org}/{repo}");
4446

4547
ImportOptions? importOptions;
@@ -70,7 +72,7 @@ await serviceWorker.ProcessIssue(
7072
else
7173
{
7274
await serviceWorker.ProcessIssues(
73-
org, repo, duration ?? -1, false);
75+
org, repo, duration ?? -1, true);
7476
}
7577
}
7678
catch (InvalidOperationException e) when (e.Message.StartsWith("HTTP error:"))

actions/sequester/Quest2GitHub/QuestGitHubService.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,19 @@ public async Task ProcessIssues(string organization, string repository, int dura
7373
int totalSkipped = 0;
7474

7575
Console.WriteLine("----- Starting processing issues. --------");
76-
var issueQueryEnumerable = QueryIssuesOrPullRequests<QuestIssue>();
76+
var issueQueryEnumerable = (duration == -1) ?
77+
QueryAllOpenIssuesOrPullRequests<QuestIssue>() :
78+
QueryIssuesOrPullRequests<QuestIssue>();
7779
await ProcessItems(issueQueryEnumerable);
7880
Console.WriteLine("----- Finished processing issues. --------");
7981
Console.WriteLine(" ----- Regenerating bearer token ------");
8082
await ghClient.RegenerateBearerToken();
8183
try
8284
{
8385
Console.WriteLine("----- Starting processing pull requests. --------");
84-
var prQueryEnumerable = QueryIssuesOrPullRequests<QuestPullRequest>();
86+
var prQueryEnumerable = (duration == -1) ?
87+
QueryAllOpenIssuesOrPullRequests<QuestPullRequest>() :
88+
QueryIssuesOrPullRequests<QuestPullRequest>();
8589
await ProcessItems(prQueryEnumerable);
8690
Console.WriteLine("----- Finished processing pull requests. --------");
8791
} catch (InvalidOperationException e)
@@ -124,7 +128,7 @@ async Task ProcessItems(IAsyncEnumerable<QuestIssueOrPullRequest> items)
124128
async IAsyncEnumerable<QuestIssueOrPullRequest> QueryIssuesOrPullRequests<T>() where T : QuestIssueOrPullRequest, IGitHubQueryResult<T, QuestIssueOrPullRequestVariables>
125129
{
126130
var query = new EnumerationQuery<T, QuestIssueOrPullRequestVariables>(ghClient);
127-
var queryEnumerable = query.PerformQuery(new QuestIssueOrPullRequestVariables(organization, repository, importTriggerLabelText: importTriggerLabelText, importedLabelText: importedLabelText));
131+
var queryEnumerable = query.PerformQuery(new QuestIssueOrPullRequestVariables(organization, repository, [], importTriggerLabelText: importTriggerLabelText, importedLabelText: importedLabelText));
128132
await foreach (QuestIssueOrPullRequest item in queryEnumerable)
129133
{
130134
if (item.UpdatedAt < historyThreshold)
@@ -133,6 +137,16 @@ async IAsyncEnumerable<QuestIssueOrPullRequest> QueryIssuesOrPullRequests<T>() w
133137
yield return item;
134138
}
135139
}
140+
141+
async IAsyncEnumerable<QuestIssueOrPullRequest> QueryAllOpenIssuesOrPullRequests<T>() where T : QuestIssueOrPullRequest, IGitHubQueryResult<T, QuestIssueOrPullRequestVariables>
142+
{
143+
var query = new EnumerationQuery<T, QuestIssueOrPullRequestVariables>(ghClient);
144+
var queryEnumerable = query.PerformQuery(new QuestIssueOrPullRequestVariables(organization, repository, ["OPEN"], importTriggerLabelText: importTriggerLabelText, importedLabelText: importedLabelText));
145+
await foreach (QuestIssueOrPullRequest item in queryEnumerable)
146+
{
147+
yield return item;
148+
}
149+
}
136150
}
137151

138152
/// <summary>
@@ -221,13 +235,13 @@ public void Dispose()
221235
private Task<QuestIssue?> RetrieveIssueAsync(string org, string repo, int issueNumber)
222236
{
223237
var query = new ScalarQuery<QuestIssue, QuestIssueOrPullRequestVariables>(ghClient);
224-
return query.PerformQuery(new QuestIssueOrPullRequestVariables(org, repo, issueNumber));
238+
return query.PerformQuery(new QuestIssueOrPullRequestVariables(org, repo, [], issueNumber));
225239
}
226240

227241
private Task<QuestPullRequest?> RetrievePullRequestAsync(string org, string repo, int issueNumber)
228242
{
229243
var query = new ScalarQuery<QuestPullRequest, QuestIssueOrPullRequestVariables>(ghClient);
230-
return query.PerformQuery(new QuestIssueOrPullRequestVariables(org, repo, issueNumber));
244+
return query.PerformQuery(new QuestIssueOrPullRequestVariables(org, repo, [], issueNumber));
231245
}
232246
private async Task<QuestIteration[]> RetrieveIterationLabelsAsync()
233247
{

0 commit comments

Comments
 (0)