Skip to content

Commit b96677b

Browse files
Merge pull request #1692 from tmandry/triage-meeting-project
Use project to get scheduled meetings
2 parents 79690e4 + d1b57f9 commit b96677b

File tree

4 files changed

+74
-29
lines changed

4 files changed

+74
-29
lines changed

github-graphql/src/lib.rs

+32-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
pub mod queries {
88
use super::schema;
99

10+
pub type Date = chrono::NaiveDate;
1011
pub type DateTime = chrono::DateTime<chrono::Utc>;
1112

13+
cynic::impl_scalar!(Date, schema::Date);
1214
cynic::impl_scalar!(DateTime, schema::DateTime);
1315

1416
#[derive(cynic::QueryVariables, Debug, Clone)]
@@ -272,8 +274,8 @@ mod schema {
272274
}
273275

274276
#[cynic::schema_for_derives(file = "src/github.graphql", module = "schema")]
275-
pub mod project_items_by_status {
276-
use super::queries::{PageInfo, Uri};
277+
pub mod project_items {
278+
use super::queries::{Date, PageInfo, Uri};
277279
use super::schema;
278280

279281
#[derive(cynic::QueryVariables, Debug, Clone)]
@@ -312,13 +314,25 @@ pub mod project_items_by_status {
312314
#[derive(cynic::QueryFragment, Debug)]
313315
pub struct ProjectV2Item {
314316
pub content: Option<ProjectV2ItemContent>,
317+
318+
// Currently we hard code the field names we care about here.
319+
#[cynic(rename = "fieldValueByName")]
315320
#[arguments(name = "Status")]
316-
pub field_value_by_name: Option<ProjectV2ItemFieldValue>,
321+
pub status: Option<ProjectV2ItemFieldValue>,
322+
#[cynic(rename = "fieldValueByName")]
323+
#[arguments(name = "Date")]
324+
pub date: Option<ProjectV2ItemFieldValue>,
317325
}
318326

319327
impl ProjectV2Item {
320-
pub fn status(&self) -> &Option<ProjectV2ItemFieldValue> {
321-
&self.field_value_by_name
328+
pub fn status(&self) -> Option<&str> {
329+
let Some(ref status) = self.status else { return None };
330+
status.as_str()
331+
}
332+
333+
pub fn date(&self) -> Option<Date> {
334+
let Some(ref date) = self.date else { return None };
335+
date.as_date()
322336
}
323337
}
324338

@@ -333,6 +347,7 @@ pub mod project_items_by_status {
333347
#[derive(cynic::InlineFragments, Debug)]
334348
pub enum ProjectV2ItemFieldValue {
335349
ProjectV2ItemFieldSingleSelectValue(ProjectV2ItemFieldSingleSelectValue),
350+
ProjectV2ItemFieldDateValue(ProjectV2ItemFieldDateValue),
336351

337352
#[cynic(fallback)]
338353
Other,
@@ -345,6 +360,13 @@ pub mod project_items_by_status {
345360
_ => return None,
346361
})
347362
}
363+
364+
pub fn as_date(&self) -> Option<Date> {
365+
match self {
366+
Self::ProjectV2ItemFieldDateValue(val) => val.date,
367+
_ => None,
368+
}
369+
}
348370
}
349371

350372
#[derive(cynic::QueryFragment, Debug)]
@@ -358,4 +380,9 @@ pub mod project_items_by_status {
358380
pub struct ProjectV2ItemFieldSingleSelectValue {
359381
pub name: Option<String>,
360382
}
383+
384+
#[derive(cynic::QueryFragment, Debug)]
385+
pub struct ProjectV2ItemFieldDateValue {
386+
pub date: Option<Date>,
387+
}
361388
}

src/agenda.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,8 @@ pub fn lang<'a>() -> Box<dyn Action + Send + Sync> {
475475
QueryMap {
476476
name: "scheduled_meetings",
477477
kind: QueryKind::List,
478-
query: Arc::new(github::Query {
479-
filters: vec![("state", "open"), ("is", "issue")],
480-
include_labels: vec!["meeting-proposal", "meeting-scheduled"],
481-
exclude_labels: vec![],
478+
query: Arc::new(github::DesignMeetings {
479+
with_status: github::DesignMeetingStatus::Scheduled,
482480
}),
483481
},
484482
],
@@ -596,7 +594,9 @@ pub fn lang_planning<'a>() -> Box<dyn Action + Send + Sync> {
596594
QueryMap {
597595
name: "proposed_meetings",
598596
kind: QueryKind::List,
599-
query: Arc::new(github::ProposedDesignMeetings),
597+
query: Arc::new(github::DesignMeetings {
598+
with_status: github::DesignMeetingStatus::Proposed,
599+
}),
600600
},
601601
],
602602
},

src/github.rs

+35-19
Original file line numberDiff line numberDiff line change
@@ -2168,23 +2168,23 @@ impl IssuesQuery for LeastRecentlyReviewedPullRequests {
21682168
async fn project_items_by_status(
21692169
client: &GithubClient,
21702170
status_filter: impl Fn(Option<&str>) -> bool,
2171-
) -> anyhow::Result<Vec<github_graphql::project_items_by_status::ProjectV2ItemContent>> {
2171+
) -> anyhow::Result<Vec<github_graphql::project_items::ProjectV2Item>> {
21722172
use cynic::QueryBuilder;
2173-
use github_graphql::project_items_by_status;
2173+
use github_graphql::project_items;
21742174

21752175
const DESIGN_MEETING_PROJECT: i32 = 31;
2176-
let mut args = project_items_by_status::Arguments {
2176+
let mut args = project_items::Arguments {
21772177
project_number: DESIGN_MEETING_PROJECT,
21782178
after: None,
21792179
};
21802180

21812181
let mut all_items = vec![];
21822182
loop {
2183-
let query = project_items_by_status::Query::build(args.clone());
2183+
let query = project_items::Query::build(args.clone());
21842184
let req = client.post(Repository::GITHUB_GRAPHQL_API_URL);
21852185
let req = req.json(&query);
21862186

2187-
let data: cynic::GraphQlResponse<project_items_by_status::Query> = client.json(req).await?;
2187+
let data: cynic::GraphQlResponse<project_items::Query> = client.json(req).await?;
21882188
if let Some(errors) = data.errors {
21892189
anyhow::bail!("There were graphql errors. {:?}", errors);
21902190
}
@@ -2201,14 +2201,7 @@ async fn project_items_by_status(
22012201
.ok_or_else(|| anyhow!("Malformed response."))?
22022202
.into_iter()
22032203
.flatten()
2204-
.filter(|item| {
2205-
status_filter(
2206-
item.field_value_by_name
2207-
.as_ref()
2208-
.and_then(|status| status.as_str()),
2209-
)
2210-
})
2211-
.flat_map(|item| item.content);
2204+
.filter(|item| status_filter(item.status()));
22122205
all_items.extend(filtered);
22132206

22142207
let page_info = items.page_info;
@@ -2218,26 +2211,49 @@ async fn project_items_by_status(
22182211
args.after = page_info.end_cursor;
22192212
}
22202213

2214+
all_items.sort_by_key(|item| item.date());
22212215
Ok(all_items)
22222216
}
22232217

2224-
pub struct ProposedDesignMeetings;
2218+
pub enum DesignMeetingStatus {
2219+
Proposed,
2220+
Scheduled,
2221+
Done,
2222+
Empty,
2223+
}
2224+
2225+
impl DesignMeetingStatus {
2226+
fn query_str(&self) -> Option<&str> {
2227+
match self {
2228+
DesignMeetingStatus::Proposed => Some("Needs triage"),
2229+
DesignMeetingStatus::Scheduled => Some("Scheduled"),
2230+
DesignMeetingStatus::Done => Some("Done"),
2231+
DesignMeetingStatus::Empty => None,
2232+
}
2233+
}
2234+
}
2235+
2236+
pub struct DesignMeetings {
2237+
pub with_status: DesignMeetingStatus,
2238+
}
2239+
22252240
#[async_trait]
2226-
impl IssuesQuery for ProposedDesignMeetings {
2241+
impl IssuesQuery for DesignMeetings {
22272242
async fn query<'a>(
22282243
&'a self,
22292244
_repo: &'a Repository,
22302245
_include_fcp_details: bool,
22312246
client: &'a GithubClient,
22322247
) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
2233-
use github_graphql::project_items_by_status::ProjectV2ItemContent;
2248+
use github_graphql::project_items::ProjectV2ItemContent;
22342249

22352250
let items =
2236-
project_items_by_status(client, |status| status == Some("Needs triage")).await?;
2251+
project_items_by_status(client, |status| status == self.with_status.query_str())
2252+
.await?;
22372253
Ok(items
22382254
.into_iter()
2239-
.flat_map(|item| match item {
2240-
ProjectV2ItemContent::Issue(issue) => Some(crate::actions::IssueDecorator {
2255+
.flat_map(|item| match item.content {
2256+
Some(ProjectV2ItemContent::Issue(issue)) => Some(crate::actions::IssueDecorator {
22412257
assignees: String::new(),
22422258
number: issue.number.try_into().unwrap(),
22432259
fcp_details: None,

templates/lang_agenda.tt

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ tags: triage-meeting
2424

2525
{{-issues::render(issues=scheduled_meetings, indent="", empty="No pending proposals this time.")}}
2626

27+
Edit the schedule here: https://github.com/orgs/rust-lang/projects/31/views/7.
28+
2729
## Announcements or custom items
2830

2931
(Meeting attendees, feel free to add items here!)

0 commit comments

Comments
 (0)