Open Source Team Metrics based on PRs
1// Database entity types
2
3export interface User {
4 id: string;
5 name: string | null;
6 email: string | null;
7 image: string | null;
8 created_at: string;
9 updated_at: string;
10}
11
12export interface Organization {
13 id: number;
14 github_id: number;
15 name: string;
16 avatar_url: string | null;
17 created_at: string;
18 updated_at: string;
19 installation_id?: number | null;
20}
21
22export interface UserOrganization {
23 user_id: string;
24 organization_id: number;
25 role: 'member' | 'admin' | 'owner';
26 created_at: string;
27}
28
29export interface Repository {
30 id: number;
31 github_id: number;
32 organization_id: number | null;
33 name: string;
34 full_name: string;
35 description: string | null;
36 private: boolean;
37 is_tracked: boolean;
38 created_at: string;
39 updated_at: string;
40}
41
42export interface Category {
43 id: number;
44 organization_id: number | null;
45 name: string;
46 description: string | null;
47 color: string | null;
48 is_default: boolean;
49 created_at: string;
50 updated_at: string;
51}
52
53export interface PullRequest {
54 id: number;
55 github_id: number;
56 repository_id: number;
57 number: number;
58 title: string;
59 description: string | null;
60 author_id: string | null;
61 state: 'open' | 'closed' | 'merged';
62 created_at: string;
63 updated_at: string;
64 closed_at: string | null;
65 merged_at: string | null;
66 draft: boolean;
67 additions: number | null;
68 deletions: number | null;
69 changed_files: number | null;
70 category_id: number | null;
71 category_confidence: number | null;
72 embedding_id: number | null;
73 ai_status?: 'pending' | 'processing' | 'completed' | 'error' | 'skipped' | string | null;
74 error_message?: string | null;
75}
76
77export interface PRReview {
78 id: number;
79 github_id: number;
80 pull_request_id: number;
81 reviewer_id: string | null;
82 state: 'approved' | 'changes_requested' | 'commented' | 'dismissed';
83 submitted_at: string;
84}
85
86export interface Setting {
87 id: number;
88 user_id: string | null;
89 organization_id: number | null;
90 key: string;
91 value: string | null;
92 created_at: string;
93 updated_at: string;
94}
95
96export interface Recommendation {
97 id: number;
98 organization_id: number;
99 title: string;
100 description: string;
101 recommendation_type: 'process' | 'technical' | 'workflow' | string;
102 status: 'open' | 'accepted' | 'rejected' | 'implemented';
103 priority: number;
104 created_at: string;
105 updated_at: string;
106}
107
108export interface Embedding {
109 id: number;
110 source_type: 'pull_request' | 'category' | string;
111 source_id: number;
112 vector: Uint8Array | null;
113 created_at: string;
114}
115
116export interface Team {
117 id: number;
118 organization_id: number;
119 name: string;
120 description: string | null;
121 color: string | null;
122 created_at: string;
123 updated_at: string;
124}
125
126export interface TeamMember {
127 id: number;
128 team_id: number;
129 user_id: string;
130 role: 'member' | 'lead' | 'admin';
131 joined_at: string;
132 created_at: string;
133 updated_at: string;
134}
135
136// Extended types for UI components
137export interface TeamWithMembers extends Team {
138 members: (TeamMember & { user: User })[];
139 member_count: number;
140}
141
142export interface UserWithTeams extends User {
143 teams: (TeamMember & { team: Team })[];
144}
145
146// GitHub API response types
147
148export interface GitHubUser {
149 id: number;
150 login: string;
151 avatar_url: string;
152 html_url: string;
153 name?: string;
154 email?: string;
155}
156
157export interface GitHubOrganization {
158 id: number;
159 login: string;
160 avatar_url: string;
161 description?: string;
162}
163
164export interface GitHubRepository {
165 id: number;
166 name: string;
167 full_name: string;
168 owner: {
169 id: number;
170 login: string;
171 type: 'User' | 'Organization';
172 };
173 installation?: {
174 id: number;
175 };
176 html_url: string;
177 description?: string;
178 private: boolean;
179 created_at: string;
180 updated_at: string;
181 pushed_at: string;
182 language?: string;
183 default_branch: string;
184}
185
186export interface GitHubPullRequest {
187 id: number;
188 number: number;
189 state: string;
190 title: string;
191 body?: string;
192 user: GitHubUser;
193 created_at: string;
194 updated_at: string;
195 closed_at: string | null;
196 merged_at: string | null;
197 draft: boolean;
198 additions?: number;
199 deletions?: number;
200 changed_files?: number;
201 head: {
202 ref: string;
203 sha: string;
204 };
205 base: {
206 ref: string;
207 sha: string;
208 };
209}