@@ -286,50 +286,32 @@ impl LDNApplication {
286
286
}
287
287
288
288
pub async fn all_applications ( ) -> Result < Vec < ( ApplicationFile , String , String ) > , Vec < LDNError > > {
289
- //TODO: Avoid filtering by allocators. Simply get all active & merged applications from the database.
290
- let allocators = match database:: allocators:: get_allocators ( ) . await {
291
- Ok ( allocs) => allocs,
292
- Err ( e) => return Err ( vec ! [ LDNError :: Load ( format!( "Failed to retrieve allocators: {}" , e) ) ] ) ,
293
- } ; let mut all_apps: Vec < ( ApplicationFile , String , String ) > = Vec :: new ( ) ;
294
- let mut errors: Vec < LDNError > = Vec :: new ( ) ;
295
-
296
- for allocator in allocators {
297
- match Self :: active ( allocator. owner . clone ( ) , allocator. repo . clone ( ) , None ) . await {
298
- Ok ( apps) => {
299
- for app in apps {
300
- all_apps. push ( ( app, allocator. owner . clone ( ) , allocator. repo . clone ( ) ) ) ;
301
- }
302
- } ,
303
- Err ( e) => {
304
- errors. push ( e) ;
305
- eprintln ! ( "Failed to process active applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
306
- } ,
307
- }
308
-
309
- match Self :: merged ( allocator. owner . clone ( ) , allocator. repo . clone ( ) ) . await {
310
- Ok ( merged_apps) => {
311
- for ( _, app) in merged_apps {
312
- all_apps. push ( ( app, allocator. owner . clone ( ) , allocator. repo . clone ( ) ) ) ;
313
- }
314
- } ,
315
- Err ( e) => {
316
- errors. push ( e) ;
317
- eprintln ! ( "Failed to process merged applications for allocator {}:{}" , allocator. repo, allocator. owner) ;
318
- } ,
319
- }
320
- }
321
-
322
- if errors. is_empty ( ) {
323
- Ok ( all_apps)
324
- } else {
325
- Err ( errors)
289
+ let db_apps = database:: applications:: get_applications ( ) . await ;
290
+ let mut all_apps: Vec < ( ApplicationFile , String , String ) > = Vec :: new ( ) ;
291
+ match db_apps {
292
+ Ok ( apps) => {
293
+ for app in apps {
294
+ let app_file = match ApplicationFile :: from_str ( & app. application . unwrap ( ) ) {
295
+ Ok ( app) => app,
296
+ Err ( e) => {
297
+ return Err ( vec ! [ LDNError :: Load ( format!( "Failed to parse application file from DB /// {}" , e) ) ] ) ;
298
+ }
299
+ } ;
300
+ all_apps. push ( ( app_file, app. owner , app. repo ) ) ;
301
+ }
302
+ return Ok ( all_apps) ;
303
+ } ,
304
+ Err ( e) => {
305
+ return Err ( vec ! [ LDNError :: Load ( format!( "Failed to retrieve applications from the database /// {}" , e) ) ] ) ;
306
+ } ,
326
307
}
308
+
327
309
}
328
310
329
311
330
312
pub async fn active ( owner : String , repo : String , filter : Option < String > ) -> Result < Vec < ApplicationFile > , LDNError > {
331
313
// Get all active applications from the database.
332
- let active_apps_result = database:: applications:: get_active_applications ( owner, repo) . await ;
314
+ let active_apps_result = database:: applications:: get_active_applications ( Some ( owner) , Some ( repo) ) . await ;
333
315
334
316
// Handle errors in getting active applications.
335
317
let active_apps = match active_apps_result {
@@ -351,7 +333,8 @@ impl LDNApplication {
351
333
if let Some ( app_json) = app_model. application {
352
334
match from_str :: < ApplicationFile > ( & app_json) {
353
335
Ok ( app) => apps. push ( app) ,
354
- Err ( e) => return Err ( LDNError :: Load ( format ! ( "Failed to parse application file: {}" , e) ) ) ,
336
+ //if error, don't push into apps
337
+ Err ( _) => { }
355
338
}
356
339
}
357
340
}
@@ -930,7 +913,7 @@ impl LDNApplication {
930
913
931
914
pub async fn merged ( owner : String , repo : String ) -> Result < Vec < ( ApplicationGithubInfo , ApplicationFile ) > , LDNError > {
932
915
// Retrieve all applications in the main branch from the database.
933
- let merged_apps_result = database:: applications:: get_merged_applications ( owner. clone ( ) , repo. clone ( ) ) . await ;
916
+ let merged_apps_result = database:: applications:: get_merged_applications ( Some ( owner. clone ( ) ) , Some ( repo. clone ( ) ) ) . await ;
934
917
935
918
// Handle errors in getting applications from the main branch.
936
919
let merged_app_models = match merged_apps_result {
@@ -946,7 +929,7 @@ impl LDNApplication {
946
929
if let Some ( app_json) = app_model. application {
947
930
match from_str :: < ApplicationFile > ( & app_json) {
948
931
Ok ( app) => merged_apps. push ( ( ApplicationGithubInfo { sha : app_model. sha . unwrap ( ) , path : app_model. path . unwrap ( ) } , app) ) ,
949
- Err ( e ) => return Err ( LDNError :: Load ( format ! ( "Failed to parse application file: {}" , e ) ) ) ,
932
+ Err ( _ ) => { } ,
950
933
}
951
934
}
952
935
}
@@ -1803,7 +1786,7 @@ Your Datacap Allocation Request has been {} by the Notary
1803
1786
1804
1787
pub async fn cache_renewal_active ( owner : String , repo : String ) -> Result < ( ) , LDNError > {
1805
1788
let active_from_gh: Vec < ApplicationFileWithDate > = LDNApplication :: active_apps_with_last_update ( owner. clone ( ) , repo. clone ( ) , None ) . await ?;
1806
- let active_from_db: Vec < ApplicationModel > = database:: applications:: get_active_applications ( owner. clone ( ) , repo. clone ( ) ) . await . unwrap ( ) ;
1789
+ let active_from_db: Vec < ApplicationModel > = database:: applications:: get_active_applications ( Some ( owner. clone ( ) ) , Some ( repo. clone ( ) ) ) . await . unwrap ( ) ;
1807
1790
1808
1791
let mut db_apps_set: HashSet < String > = HashSet :: new ( ) ;
1809
1792
let mut processed_gh_apps: HashSet < String > = HashSet :: new ( ) ;
@@ -1860,7 +1843,7 @@ Your Datacap Allocation Request has been {} by the Notary
1860
1843
1861
1844
pub async fn cache_renewal_merged ( owner : String , repo : String ) -> Result < ( ) , LDNError > {
1862
1845
let merged_from_gh: Vec < ApplicationFileWithDate > = LDNApplication :: merged_apps_with_last_update ( owner. clone ( ) , repo. clone ( ) , None ) . await ?;
1863
- let merged_from_db: Vec < ApplicationModel > = database:: applications:: get_merged_applications ( owner. clone ( ) , repo. clone ( ) ) . await . unwrap ( ) ;
1846
+ let merged_from_db: Vec < ApplicationModel > = database:: applications:: get_merged_applications ( Some ( owner. clone ( ) ) , Some ( repo. clone ( ) ) ) . await . unwrap ( ) ;
1864
1847
1865
1848
let mut db_apps_set: HashSet < String > = HashSet :: new ( ) ;
1866
1849
let mut processed_gh_apps: HashSet < String > = HashSet :: new ( ) ;
0 commit comments