@@ -238,29 +238,46 @@ impl LDNApplication {
238
238
} ) ;
239
239
}
240
240
241
- pub async fn all_applications ( ) -> Result < Vec < ApplicationFile > , LDNError > {
242
- let allocators = database:: get_allocators ( ) . await . map_err ( |e| LDNError :: Load ( format ! ( "Failed to retrieve allocators /// {}" , e) ) ) ?;
241
+ pub async fn all_applications ( ) -> Result < Vec < ( ApplicationFile , String , String ) > , Vec < LDNError > > {
242
+ let allocators = match database:: get_allocators ( ) . await {
243
+ Ok ( allocs) => allocs,
244
+ Err ( e) => return Err ( vec ! [ LDNError :: Load ( format!( "Failed to retrieve allocators: {}" , e) ) ] ) ,
245
+ } ; let mut all_apps: Vec < ( ApplicationFile , String , String ) > = Vec :: new ( ) ;
246
+ let mut errors: Vec < LDNError > = Vec :: new ( ) ;
243
247
244
- let mut all_apps: Vec < ApplicationFile > = Vec :: new ( ) ;
245
248
for allocator in allocators {
246
- // Process active applications
247
- if let Ok ( apps) = Self :: active ( allocator. owner . clone ( ) , allocator. repo . clone ( ) , None ) . await {
248
- all_apps. extend ( apps) ;
249
- } else {
250
- eprintln ! ( "Failed to process active applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
249
+ match Self :: active ( allocator. owner . clone ( ) , allocator. repo . clone ( ) , None ) . await {
250
+ Ok ( apps) => {
251
+ for app in apps {
252
+ all_apps. push ( ( app, allocator. repo . clone ( ) , allocator. owner . clone ( ) ) ) ;
253
+ }
254
+ } ,
255
+ Err ( e) => {
256
+ errors. push ( e) ;
257
+ eprintln ! ( "Failed to process active applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
258
+ } ,
251
259
}
252
260
253
- // Process merged applications
254
- if let Ok ( merged_apps) = Self :: merged ( allocator. owner . clone ( ) , allocator. repo . clone ( ) ) . await {
255
- // Assuming you only need ApplicationFile from the tuple (Content, ApplicationFile)
256
- all_apps. extend ( merged_apps. into_iter ( ) . map ( |( _, app_file) | app_file) ) ;
257
- } else {
258
- eprintln ! ( "Failed to process merged applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
261
+ match Self :: merged ( allocator. owner . clone ( ) , allocator. repo . clone ( ) ) . await {
262
+ Ok ( merged_apps) => {
263
+ for app in merged_apps {
264
+ all_apps. push ( ( app. 1 , allocator. repo . clone ( ) , allocator. owner . clone ( ) ) ) ;
265
+ }
266
+ } ,
267
+ Err ( e) => {
268
+ errors. push ( e) ;
269
+ eprintln ! ( "Failed to process merged applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
270
+ } ,
259
271
}
260
272
}
261
273
262
- Ok ( all_apps)
274
+ if errors. is_empty ( ) {
275
+ Ok ( all_apps)
276
+ } else {
277
+ Err ( errors)
278
+ }
263
279
}
280
+
264
281
265
282
pub async fn active ( owner : String , repo : String , filter : Option < String > ) -> Result < Vec < ApplicationFile > , LDNError > {
266
283
let gh: GithubWrapper = GithubWrapper :: new ( owner. clone ( ) , repo. clone ( ) ) ;
0 commit comments