Add total amount of branches after filter
parent: tbd commit: c29b3b8
1 | use |
2 | , | UserAuthenticationToken
3 | , |
4 | |
5 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
6 | , |
7 | , | ObjectBackend
8 | |
9 | Commit, DefaultBranch, Description, LatestCommit, Repository, RepositoryBranch, |
10 | RepositoryBranchesRequest, RepositoryCommitBeforeRequest, RepositoryCommitFromIdRequest, |
11 | RepositoryDiff, RepositoryDiffPatchRequest, RepositoryDiffRequest, RepositoryFile, |
12 | RepositoryFileFromIdRequest, RepositoryFileFromPathRequest, RepositoryFileInspectRequest, |
13 | RepositoryInfoRequest, RepositoryLastCommitOfFileRequest, RepositoryStatistics, |
14 | RepositoryStatisticsRequest, RepositorySummary, RepositoryView, Visibility, |
15 | , |
16 | , |
17 | ; |
18 | use ; |
19 | |
20 | use DatabaseBackend; |
21 | |
22 | pub async |
23 | object: User, |
24 | _operation: UserRepositoriesRequest, |
25 | state: DatabaseBackend, |
26 | OperationState | : ,
27 | requester: , |
28 | |
29 | let object = object.clone; |
30 | |
31 | let mut user_backend = state.user_backend.lock .await; |
32 | let repositories_response = user_backend |
33 | .repositories_for_user |
34 | .await |
35 | .as_internal_error?; |
36 | drop; |
37 | let mut repositories_backend = state.repository_backend.lock .await; |
38 | |
39 | let mut repositories = vec!; |
40 | |
41 | for repository in repositories_response |
42 | if repositories_backend |
43 | .exists |
44 | .await |
45 | .as_internal_error? |
46 | |
47 | repositories.push; |
48 | |
49 | |
50 | |
51 | Ok |
52 | |
53 | |
54 | pub async |
55 | object: Repository, |
56 | operation: RepositoryInfoRequest, |
57 | state: DatabaseBackend, |
58 | OperationState | : ,
59 | backend: GiteratedStack, |
60 | requester: , |
61 | |
62 | info!; |
63 | let mut object = backend |
64 | . |
65 | .await |
66 | .unwrap; |
67 | let mut repository_backend = state.repository_backend.lock .await; |
68 | let tree = repository_backend |
69 | .repository_file_inspect |
70 | &requester, |
71 | object.object, |
72 | &RepositoryFileInspectRequest |
73 | extra_metadata: operation.extra_metadata, |
74 | path: operation.path.clone, |
75 | rev: operation.rev.clone, |
76 | , |
77 | |
78 | .await |
79 | .as_internal_error?; |
80 | |
81 | let statistics = repository_backend |
82 | .repository_get_statistics |
83 | &requester, |
84 | object.object, |
85 | &RepositoryStatisticsRequest |
86 | rev: operation.rev.clone, |
87 | , |
88 | |
89 | .await |
90 | .as_internal_error?; |
91 | drop; |
92 | |
93 | let info = RepositoryView |
94 | name: object.object .name.clone, |
95 | owner: object.object .owner.clone, |
96 | description: object. .await.ok, |
97 | visibility: object |
98 | . |
99 | .await |
100 | .as_internal_error?, |
101 | default_branch: object |
102 | . |
103 | .await |
104 | .as_internal_error?, |
105 | // TODO: Can't be a simple get function, this needs to be returned alongside the tree as this differs depending on the rev and path. |
106 | latest_commit: object. .await.ok, |
107 | stats: statistics, |
108 | tree_rev: operation.rev.clone, |
109 | tree, |
110 | ; |
111 | |
112 | Ok |
113 | |
114 | |
115 | pub async |
116 | object: Repository, |
117 | operation: RepositoryStatisticsRequest, |
118 | state: DatabaseBackend, |
119 | OperationState | : ,
120 | backend: GiteratedStack, |
121 | requester: , |
122 | |
123 | let object = backend |
124 | . |
125 | .await |
126 | .unwrap; |
127 | |
128 | let mut repository_backend = state.repository_backend.lock .await; |
129 | let statistics = repository_backend |
130 | .repository_get_statistics |
131 | &requester, |
132 | object.object, |
133 | &RepositoryStatisticsRequest |
134 | rev: operation.rev.clone, |
135 | , |
136 | |
137 | .await |
138 | .as_internal_error?; |
139 | drop; |
140 | |
141 | Ok |
142 | |
143 | |
144 | pub async |
145 | object: Repository, |
146 | operation: RepositoryBranchesRequest, |
147 | state: DatabaseBackend, |
148 | OperationState | : ,
149 | backend: GiteratedStack, |
150 | requester: , |
151 | |
152 | let object = backend |
153 | . |
154 | .await |
155 | .unwrap; |
156 | |
157 | let mut repository_backend = state.repository_backend.lock .await; |
158 | let branches = repository_backend |
159 | .repository_get_branches |
160 | .await |
161 | .as_internal_error?; |
162 | drop; |
163 | |
164 | Ok |
165 | |
166 | |
167 | pub async |
168 | object: Repository, |
169 | operation: RepositoryFileFromIdRequest, |
170 | state: DatabaseBackend, |
171 | OperationState | : ,
172 | backend: GiteratedStack, |
173 | requester: , |
174 | |
175 | let object = backend |
176 | . |
177 | .await |
178 | .unwrap; |
179 | |
180 | let mut repository_backend = state.repository_backend.lock .await; |
181 | let file = repository_backend |
182 | .repository_file_from_id |
183 | &requester, |
184 | object.object, |
185 | &RepositoryFileFromIdRequest, |
186 | |
187 | .await |
188 | .as_internal_error?; |
189 | drop; |
190 | |
191 | Ok |
192 | |
193 | |
194 | pub async |
195 | object: Repository, |
196 | operation: RepositoryFileFromPathRequest, |
197 | state: DatabaseBackend, |
198 | OperationState | : ,
199 | backend: GiteratedStack, |
200 | requester: , |
201 | |
202 | let object = backend |
203 | . |
204 | .await |
205 | .unwrap; |
206 | |
207 | let mut repository_backend = state.repository_backend.lock .await; |
208 | let file = repository_backend |
209 | .repository_file_from_path |
210 | &requester, |
211 | object.object, |
212 | &RepositoryFileFromPathRequest |
213 | rev: operation.rev.clone, |
214 | path: operation.path.clone, |
215 | , |
216 | |
217 | .await |
218 | .as_internal_error?; |
219 | drop; |
220 | |
221 | Ok |
222 | |
223 | |
224 | pub async |
225 | object: Repository, |
226 | operation: RepositoryLastCommitOfFileRequest, |
227 | state: DatabaseBackend, |
228 | OperationState | : ,
229 | backend: GiteratedStack, |
230 | requester: , |
231 | |
232 | let object = backend |
233 | . |
234 | .await |
235 | .unwrap; |
236 | |
237 | let mut repository_backend = state.repository_backend.lock .await; |
238 | let commit = repository_backend |
239 | .repository_last_commit_of_file |
240 | &requester, |
241 | object.object, |
242 | &RepositoryLastCommitOfFileRequest |
243 | start_commit: operation.start_commit.clone, |
244 | path: operation.path.clone, |
245 | , |
246 | |
247 | .await |
248 | .as_internal_error?; |
249 | drop; |
250 | |
251 | Ok |
252 | |
253 | |
254 | pub async |
255 | object: Repository, |
256 | operation: RepositoryCommitFromIdRequest, |
257 | state: DatabaseBackend, |
258 | OperationState | : ,
259 | backend: GiteratedStack, |
260 | requester: , |
261 | |
262 | let object = backend |
263 | . |
264 | .await |
265 | .unwrap; |
266 | |
267 | let mut repository_backend = state.repository_backend.lock .await; |
268 | let commit = repository_backend |
269 | .repository_commit_from_id |
270 | &requester, |
271 | object.object, |
272 | &RepositoryCommitFromIdRequest, |
273 | |
274 | .await |
275 | .as_internal_error?; |
276 | drop; |
277 | |
278 | Ok |
279 | |
280 | |
281 | pub async |
282 | object: Repository, |
283 | operation: RepositoryDiffRequest, |
284 | state: DatabaseBackend, |
285 | OperationState | : ,
286 | backend: GiteratedStack, |
287 | requester: , |
288 | |
289 | let object = backend |
290 | . |
291 | .await |
292 | .unwrap; |
293 | |
294 | let mut repository_backend = state.repository_backend.lock .await; |
295 | let diff = repository_backend |
296 | .repository_diff |
297 | .await |
298 | .as_internal_error?; |
299 | drop; |
300 | |
301 | Ok |
302 | |
303 | |
304 | pub async |
305 | object: Repository, |
306 | operation: RepositoryDiffPatchRequest, |
307 | state: DatabaseBackend, |
308 | OperationState | : ,
309 | backend: GiteratedStack, |
310 | requester: , |
311 | |
312 | let object = backend |
313 | . |
314 | .await |
315 | .unwrap; |
316 | |
317 | let mut repository_backend = state.repository_backend.lock .await; |
318 | let patch = repository_backend |
319 | .repository_diff_patch |
320 | .await |
321 | .as_internal_error?; |
322 | drop; |
323 | |
324 | Ok |
325 | |
326 | |
327 | pub async |
328 | object: Repository, |
329 | operation: RepositoryCommitBeforeRequest, |
330 | state: DatabaseBackend, |
331 | OperationState | : ,
332 | backend: GiteratedStack, |
333 | requester: , |
334 | |
335 | let object = backend |
336 | . |
337 | .await |
338 | .unwrap; |
339 | |
340 | let mut repository_backend = state.repository_backend.lock .await; |
341 | let file = repository_backend |
342 | .repository_commit_before |
343 | .await |
344 | .as_internal_error?; |
345 | drop; |
346 | |
347 | Ok |
348 | |
349 | |
350 | pub async |
351 | object: Instance, |
352 | operation: AuthenticationTokenRequest, |
353 | state: DatabaseBackend, |
354 | OperationState | : ,
355 | // Authorizes the request for SAME-INSTANCE |
356 | // _authorized_instance: AuthorizedInstance, |
357 | |
358 | let mut backend = state.user_backend.lock .await; |
359 | |
360 | backend |
361 | .login |
362 | .await |
363 | .as_internal_error |
364 | |
365 | |
366 | pub async |
367 | _object: Instance, |
368 | operation: RegisterAccountRequest, |
369 | state: DatabaseBackend, |
370 | OperationState// Authorizes the request for SAME-INSTANCE | : ,
371 | // _authorized_instance: AuthorizedInstance, |
372 | |
373 | let mut backend = state.user_backend.lock .await; |
374 | |
375 | backend |
376 | .register |
377 | .await |
378 | .as_internal_error |
379 | |
380 | |
381 | pub async |
382 | _object: Instance, |
383 | operation: RepositoryCreateRequest, |
384 | state: DatabaseBackend, |
385 | OperationState | : ,
386 | requester: AuthenticatedUser, |
387 | // Authorizes the request for SAME-INSTANCE |
388 | // _authorized_instance: AuthorizedInstance, |
389 | |
390 | let mut backend = state.repository_backend.lock .await; |
391 | |
392 | backend |
393 | .create_repository |
394 | .await |
395 | .as_internal_error |
396 | |
397 | |
398 | pub async |
399 | _repository: Repository, |
400 | _state: DatabaseBackend, |
401 | OperationState | : ,
402 | |
403 | Ok |
404 | |
405 |