@@ -238,29 +238,44 @@ 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 = database:: get_allocators ( ) . await . map_err ( |_| LDNError :: new ( "Failed to get allocators from the database" ) ) ?;
243
+ let mut all_apps: Vec < ( ApplicationFile , String , String ) > = Vec :: new ( ) ;
244
+ let mut errors: Vec < LDNError > = Vec :: new ( ) ;
243
245
244
- let mut all_apps: Vec < ApplicationFile > = Vec :: new ( ) ;
245
246
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) ;
247
+ match active ( allocator. owner . clone ( ) , allocator. repo . clone ( ) , None ) . await {
248
+ Ok ( apps) => {
249
+ for app in apps {
250
+ all_apps. push ( ( app, allocator. repo . clone ( ) , allocator. owner . clone ( ) ) ) ;
251
+ }
252
+ } ,
253
+ Err ( e) => {
254
+ errors. push ( e) ;
255
+ eprintln ! ( "Failed to process active applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
256
+ } ,
251
257
}
252
258
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) ;
259
+ match merged ( allocator. owner . clone ( ) , allocator. repo . clone ( ) ) . await {
260
+ Ok ( merged_apps) => {
261
+ for app in merged_apps {
262
+ all_apps. push ( ( app. 1 , allocator. repo . clone ( ) , allocator. owner . clone ( ) ) ) ;
263
+ }
264
+ } ,
265
+ Err ( e) => {
266
+ errors. push ( e) ;
267
+ eprintln ! ( "Failed to process merged applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
268
+ } ,
259
269
}
260
270
}
261
271
262
- Ok ( all_apps)
272
+ if errors. is_empty ( ) {
273
+ Ok ( all_apps)
274
+ } else {
275
+ Err ( errors)
276
+ }
263
277
}
278
+
264
279
265
280
pub async fn active ( owner : String , repo : String , filter : Option < String > ) -> Result < Vec < ApplicationFile > , LDNError > {
266
281
let gh: GithubWrapper = GithubWrapper :: new ( owner. clone ( ) , repo. clone ( ) ) ;
0 commit comments