feat: show creation time next to pr title

This commit is contained in:
2026-05-12 02:19:08 +08:00
parent 2fe3f7b94f
commit 6168676ac0
11 changed files with 72 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ query PullRequestQuery($id: ID!) {
body
state
isDraft
createdAt
baseRef {
name
}

View File

@@ -70,6 +70,7 @@ pub(crate) struct DetailedPullRequest {
pub(crate) state: PullRequestState,
pub(crate) is_draft: bool,
pub(crate) body: String,
pub(crate) created_at: Option<chrono::DateTime<chrono::FixedOffset>>,
pub(crate) author: Option<super::user::Actor>,
pub(crate) base_branch_name: Option<String>,
pub(crate) head_branch_name: Option<String>,
@@ -368,18 +369,29 @@ impl query::QueryFn for FetchPullRequest {
"missing 'node' field on PullRequestQuery response".into(),
))
.and_then(|n| match n {
| PullRequestQueryNode::PullRequest(p) => Ok(DetailedPullRequest {
title: p.title,
state: p.state,
is_draft: p.is_draft,
body: p.body,
author: p.author.map(|it| api::user::Actor {
login: it.login,
avatar_url: it.avatar_url,
}),
base_branch_name: p.base_ref.map(|r| r.name),
head_branch_name: p.head_ref.map(|r| r.name),
}),
| PullRequestQueryNode::PullRequest(p) => {
let created_at =
chrono::DateTime::parse_from_rfc3339(&p.created_at).map_err(|err| {
api::Error::MalformedResponse(format!(
"invalid pull request createdAt {:?}: {err}",
p.created_at
))
})?;
Ok(DetailedPullRequest {
title: p.title,
state: p.state,
is_draft: p.is_draft,
body: p.body,
author: p.author.map(|it| api::user::Actor {
login: it.login,
avatar_url: it.avatar_url,
}),
base_branch_name: p.base_ref.map(|r| r.name),
head_branch_name: p.head_ref.map(|r| r.name),
created_at: Some(created_at),
})
}
| _ => Err(api::Error::MalformedResponse(
"unexpected node type on PullRequestQuery".into(),
)),

View File

@@ -151,6 +151,10 @@ mod tests {
merged.head_branch_name.as_deref(),
Some("feat/release-handoff-checklist")
);
assert_eq!(
merged.created_at,
Some(chrono::DateTime::parse_from_rfc3339("2026-04-28T10:20:00Z").unwrap())
);
assert!(
documented_failover
.body
@@ -168,12 +172,20 @@ mod tests {
documented_failover.head_branch_name.as_deref(),
Some("docs/manual-failover-steps")
);
assert_eq!(
documented_failover.created_at,
Some(chrono::DateTime::parse_from_rfc3339("2026-04-24T06:40:00Z").unwrap())
);
assert!(dashboard_markdown.body.contains("```rust"));
assert_eq!(dashboard_markdown.base_branch_name.as_deref(), Some("main"));
assert_eq!(
dashboard_markdown.head_branch_name.as_deref(),
Some("feat/cached-issue-pane")
);
assert_eq!(
dashboard_markdown.created_at,
Some(chrono::DateTime::parse_from_rfc3339("2026-05-01T09:12:00Z").unwrap())
);
assert_eq!(
cached_repo_picker
.author
@@ -186,6 +198,10 @@ mod tests {
cached_repo_picker.head_branch_name.as_deref(),
Some("feat/cached-repo-picker")
);
assert_eq!(
cached_repo_picker.created_at,
Some(chrono::DateTime::parse_from_rfc3339("2026-05-03T07:40:00Z").unwrap())
);
assert_eq!(
worker_split.author.as_ref().map(|author| author.login.as_str()),
Some("leaferiksen")
@@ -195,6 +211,10 @@ mod tests {
worker_split.head_branch_name.as_deref(),
Some("feat/worker-context-envelope")
);
assert_eq!(
worker_split.created_at,
Some(chrono::DateTime::parse_from_rfc3339("2026-04-30T14:22:00Z").unwrap())
);
assert_eq!(
spacing_tokens
.author
@@ -207,6 +227,10 @@ mod tests {
spacing_tokens.head_branch_name.as_deref(),
Some("chore/dashboard-spacing-scale")
);
assert_eq!(
spacing_tokens.created_at,
Some(chrono::DateTime::parse_from_rfc3339("2026-05-02T11:05:00Z").unwrap())
);
}
#[test]