ricecoder_github/
models.rs

1//! GitHub Data Models
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7/// Pull Request status
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "lowercase")]
10pub enum PrStatus {
11    /// Draft PR
12    Draft,
13    /// Open PR
14    Open,
15    /// Merged PR
16    Merged,
17    /// Closed PR
18    Closed,
19}
20
21/// Issue status
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
23#[serde(rename_all = "lowercase")]
24pub enum IssueStatus {
25    /// Open issue
26    Open,
27    /// In progress
28    InProgress,
29    /// Closed issue
30    Closed,
31}
32
33/// File change in a PR
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct FileChange {
36    /// File path
37    pub path: String,
38    /// Change type (added, modified, deleted)
39    pub change_type: String,
40    /// Number of additions
41    pub additions: u32,
42    /// Number of deletions
43    pub deletions: u32,
44}
45
46/// Pull Request
47#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct PullRequest {
49    /// PR ID
50    pub id: u64,
51    /// PR number
52    pub number: u32,
53    /// PR title
54    pub title: String,
55    /// PR body/description
56    pub body: String,
57    /// Branch name
58    pub branch: String,
59    /// Base branch
60    pub base: String,
61    /// PR status
62    pub status: PrStatus,
63    /// Files changed
64    pub files: Vec<FileChange>,
65    /// Created at timestamp
66    pub created_at: DateTime<Utc>,
67    /// Updated at timestamp
68    pub updated_at: DateTime<Utc>,
69}
70
71/// Issue
72#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct Issue {
74    /// Issue ID
75    pub id: u64,
76    /// Issue number
77    pub number: u32,
78    /// Issue title
79    pub title: String,
80    /// Issue body/description
81    pub body: String,
82    /// Labels
83    pub labels: Vec<String>,
84    /// Assignees
85    pub assignees: Vec<String>,
86    /// Issue status
87    pub status: IssueStatus,
88    /// Created at timestamp
89    pub created_at: DateTime<Utc>,
90    /// Updated at timestamp
91    pub updated_at: DateTime<Utc>,
92}
93
94/// Dependency information
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct Dependency {
97    /// Dependency name
98    pub name: String,
99    /// Current version
100    pub version: String,
101    /// Latest available version
102    pub latest_version: Option<String>,
103    /// Is outdated
104    pub is_outdated: bool,
105}
106
107/// Project structure information
108#[derive(Debug, Clone, Serialize, Deserialize)]
109pub struct ProjectStructure {
110    /// Main language
111    pub language: Option<String>,
112    /// Project type (library, binary, etc.)
113    pub project_type: String,
114    /// Key directories
115    pub directories: Vec<String>,
116    /// Key files
117    pub files: Vec<String>,
118}
119
120/// Repository information
121#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct Repository {
123    /// Repository name
124    pub name: String,
125    /// Repository owner
126    pub owner: String,
127    /// Repository description
128    pub description: String,
129    /// Repository URL
130    pub url: String,
131    /// Primary language
132    pub language: Option<String>,
133    /// Dependencies
134    pub dependencies: Vec<Dependency>,
135    /// Project structure
136    pub structure: ProjectStructure,
137}
138
139/// Project card
140#[derive(Debug, Clone, Serialize, Deserialize)]
141pub struct ProjectCard {
142    /// Card ID
143    pub id: u64,
144    /// Content ID (issue or PR)
145    pub content_id: u64,
146    /// Content type (Issue or PullRequest)
147    pub content_type: String,
148    /// Column ID
149    pub column_id: u64,
150    /// Optional note
151    pub note: Option<String>,
152}
153
154/// Release information
155#[derive(Debug, Clone, Serialize, Deserialize)]
156pub struct Release {
157    /// Release ID
158    pub id: u64,
159    /// Tag name
160    pub tag_name: String,
161    /// Release name
162    pub name: String,
163    /// Release notes
164    pub body: String,
165    /// Is draft
166    pub draft: bool,
167    /// Is prerelease
168    pub prerelease: bool,
169    /// Created at timestamp
170    pub created_at: DateTime<Utc>,
171}
172
173/// Gist file
174#[derive(Debug, Clone, Serialize, Deserialize)]
175pub struct GistFile {
176    /// File name
177    pub filename: String,
178    /// File content
179    pub content: String,
180    /// File language
181    pub language: Option<String>,
182}
183
184/// GitHub Gist
185#[derive(Debug, Clone, Serialize, Deserialize)]
186pub struct Gist {
187    /// Gist ID
188    pub id: String,
189    /// Gist URL
190    pub url: String,
191    /// Files in gist
192    pub files: HashMap<String, GistFile>,
193    /// Gist description
194    pub description: String,
195    /// Is public
196    pub public: bool,
197}
198
199/// Discussion
200#[derive(Debug, Clone, Serialize, Deserialize)]
201pub struct Discussion {
202    /// Discussion ID
203    pub id: u64,
204    /// Discussion number
205    pub number: u32,
206    /// Discussion title
207    pub title: String,
208    /// Discussion body
209    pub body: String,
210    /// Category
211    pub category: String,
212    /// Created at timestamp
213    pub created_at: DateTime<Utc>,
214    /// Updated at timestamp
215    pub updated_at: DateTime<Utc>,
216}
217
218/// Progress update for an issue
219#[derive(Debug, Clone, Serialize, Deserialize)]
220pub struct IssueProgressUpdate {
221    /// Issue number
222    pub issue_number: u32,
223    /// Update message
224    pub message: String,
225    /// Current status
226    pub status: IssueStatus,
227    /// Percentage complete (0-100)
228    pub progress_percentage: u32,
229}