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