Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Work service in Rust, with RFC 3339 timestamps | 1 | //! Rows as they come out of D1, and their conversion to contract types. |
| 2 | ||
| 3 | use g1t_contracts::User; | |
| 4 | use g1t_contracts::repos::RepoPath; | |
| 5 | use g1t_contracts::work::{ | |
| Issues and pull requests replace intents and attempts | 6 | Comment, Issue, IssueReason, Pull, PullStatus, Runtime, SessionEntry, SessionEntryKind, State, |
| Work service in Rust, with RFC 3339 timestamps | 7 | }; |
| 8 | use serde::Deserialize; | |
| 9 | ||
| Issues and pull requests replace intents and attempts | 10 | fn user(id: String, username: String) -> User { |
| 11 | User { | |
| 12 | id, | |
| 13 | username, | |
| 14 | ..User::default() | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| Work service in Rust, with RFC 3339 timestamps | 18 | #[derive(Deserialize)] |
| Issues and pull requests replace intents and attempts | 19 | pub struct IssueRow { |
| Work service in Rust, with RFC 3339 timestamps | 20 | pub id: String, |
| 21 | pub repo_id: String, | |
| 22 | pub number: u32, | |
| 23 | pub title: String, | |
| Issues and pull requests replace intents and attempts | 24 | pub body: String, |
| 25 | /// JSON array of label names. | |
| 26 | pub labels: String, | |
| Work service in Rust, with RFC 3339 timestamps | 27 | /// JSON array of commands. |
| 28 | pub checks: String, | |
| Issues and pull requests replace intents and attempts | 29 | pub state: State, |
| 30 | pub reason: Option<IssueReason>, | |
| 31 | pub resolved_by: Option<u32>, | |
| Work service in Rust, with RFC 3339 timestamps | 32 | pub author_id: String, |
| 33 | pub author_name: String, | |
| 34 | pub created_at: String, | |
| Issues and pull requests replace intents and attempts | 35 | pub updated_at: String, |
| 36 | pub closed_at: Option<String>, | |
| 37 | pub pull_count: u32, | |
| 38 | pub comment_count: u32, | |
| Work service in Rust, with RFC 3339 timestamps | 39 | } |
| 40 | ||
| Issues and pull requests replace intents and attempts | 41 | impl From<IssueRow> for Issue { |
| 42 | fn from(row: IssueRow) -> Self { | |
| 43 | Issue { | |
| Work service in Rust, with RFC 3339 timestamps | 44 | id: row.id, |
| 45 | repo_id: row.repo_id, | |
| 46 | number: row.number, | |
| 47 | title: row.title, | |
| Issues and pull requests replace intents and attempts | 48 | body: row.body, |
| 49 | labels: serde_json::from_str(&row.labels).unwrap_or_default(), | |
| Work service in Rust, with RFC 3339 timestamps | 50 | checks: serde_json::from_str(&row.checks).unwrap_or_default(), |
| Issues and pull requests replace intents and attempts | 51 | state: row.state, |
| 52 | reason: row.reason, | |
| 53 | resolved_by: row.resolved_by, | |
| 54 | author: user(row.author_id, row.author_name), | |
| Work service in Rust, with RFC 3339 timestamps | 55 | created_at: row.created_at, |
| Issues and pull requests replace intents and attempts | 56 | updated_at: row.updated_at, |
| 57 | closed_at: row.closed_at, | |
| 58 | pull_count: row.pull_count, | |
| 59 | comment_count: row.comment_count, | |
| Work service in Rust, with RFC 3339 timestamps | 60 | } |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | #[derive(Deserialize)] | |
| Issues and pull requests replace intents and attempts | 65 | pub struct PullRow { |
| Work service in Rust, with RFC 3339 timestamps | 66 | pub id: String, |
| 67 | pub repo_id: String, | |
| 68 | pub number: u32, | |
| Issues and pull requests replace intents and attempts | 69 | pub issue_number: Option<u32>, |
| 70 | pub title: String, | |
| 71 | pub body: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 72 | pub agent: String, |
| Issues and pull requests replace intents and attempts | 73 | pub runtime: Runtime, |
| 74 | pub status: PullStatus, | |
| Pull requests from branches | 75 | pub fork_repo_id: Option<String>, |
| 76 | pub fork_namespace: Option<String>, | |
| 77 | pub fork_name: Option<String>, | |
| 78 | pub source_branch: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 79 | pub head_commit: Option<String>, |
| Issues and pull requests replace intents and attempts | 80 | pub merge_base: Option<String>, |
| 81 | pub merged_by: Option<String>, | |
| 82 | pub merged_at: Option<String>, | |
| 83 | pub superseded_by: Option<u32>, | |
| 84 | pub author_id: String, | |
| 85 | pub author_name: String, | |
| Work service in Rust, with RFC 3339 timestamps | 86 | pub created_at: String, |
| 87 | pub updated_at: String, | |
| 88 | } | |
| 89 | ||
| Issues and pull requests replace intents and attempts | 90 | impl From<PullRow> for Pull { |
| 91 | fn from(row: PullRow) -> Self { | |
| 92 | Pull { | |
| Work service in Rust, with RFC 3339 timestamps | 93 | id: row.id, |
| 94 | repo_id: row.repo_id, | |
| 95 | number: row.number, | |
| Issues and pull requests replace intents and attempts | 96 | issue: row.issue_number, |
| 97 | title: row.title, | |
| 98 | body: row.body, | |
| Work service in Rust, with RFC 3339 timestamps | 99 | agent: row.agent, |
| 100 | runtime: row.runtime, | |
| 101 | status: row.status, | |
| Pull requests from branches | 102 | fork: row |
| 103 | .fork_namespace | |
| 104 | .zip(row.fork_name) | |
| 105 | .map(|(namespace, name)| RepoPath { namespace, name }), | |
| Work service in Rust, with RFC 3339 timestamps | 106 | fork_repo_id: row.fork_repo_id, |
| Pull requests from branches | 107 | branch: row.source_branch, |
| Work service in Rust, with RFC 3339 timestamps | 108 | head_commit: row.head_commit, |
| Issues and pull requests replace intents and attempts | 109 | merge_base: row.merge_base, |
| 110 | merged_by: row.merged_by, | |
| 111 | merged_at: row.merged_at, | |
| 112 | superseded_by: row.superseded_by, | |
| 113 | author: user(row.author_id, row.author_name), | |
| Work service in Rust, with RFC 3339 timestamps | 114 | created_at: row.created_at, |
| 115 | updated_at: row.updated_at, | |
| 116 | } | |
| 117 | } | |
| 118 | } | |
| 119 | ||
| 120 | #[derive(Deserialize)] | |
| Issues and pull requests replace intents and attempts | 121 | pub struct CommentRow { |
| 122 | pub id: String, | |
| 123 | pub author_id: String, | |
| 124 | pub author_name: String, | |
| 125 | pub body: String, | |
| 126 | pub created_at: String, | |
| 127 | } | |
| 128 | ||
| 129 | impl From<CommentRow> for Comment { | |
| 130 | fn from(row: CommentRow) -> Self { | |
| 131 | Comment { | |
| 132 | id: row.id, | |
| 133 | author: user(row.author_id, row.author_name), | |
| 134 | body: row.body, | |
| 135 | created_at: row.created_at, | |
| 136 | } | |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | #[derive(Deserialize)] | |
| Work service in Rust, with RFC 3339 timestamps | 141 | pub struct SessionRow { |
| 142 | pub seq: u32, | |
| 143 | pub kind: SessionEntryKind, | |
| 144 | pub text: String, | |
| 145 | pub tool: Option<String>, | |
| 146 | pub commit: Option<String>, | |
| 147 | pub at: String, | |
| 148 | } | |
| 149 | ||
| 150 | impl From<SessionRow> for SessionEntry { | |
| 151 | fn from(row: SessionRow) -> Self { | |
| 152 | SessionEntry { | |
| 153 | seq: row.seq, | |
| 154 | kind: row.kind, | |
| 155 | text: row.text, | |
| 156 | tool: row.tool, | |
| 157 | commit: row.commit, | |
| 158 | at: row.at, | |
| 159 | } | |
| 160 | } | |
| 161 | } | |
| Issues and pull requests replace intents and attempts | 162 | |
| 163 | /// A single number selected as `n`. | |
| 164 | #[derive(Deserialize)] | |
| 165 | pub struct NumberRow { | |
| 166 | pub n: u32, | |
| 167 | } | |
| 168 | ||
| 169 | /// A single string selected as `value`. | |
| 170 | #[derive(Deserialize)] | |
| 171 | pub struct ValueRow { | |
| 172 | pub value: String, | |
| 173 | } |