@@ -117,6 +117,7 @@ pub struct AllocatorUpdateInfo {
117
117
pub installation_id : Option < i64 > ,
118
118
pub multisig_address : Option < String > ,
119
119
pub verifiers_gh_handles : Option < String > ,
120
+ pub multisig_threshold : Option < i32 > ,
120
121
}
121
122
122
123
#[ derive( Deserialize ) ]
@@ -292,61 +293,31 @@ impl LDNApplication {
292
293
}
293
294
294
295
pub async fn all_applications ( ) -> Result < Vec < ( ApplicationFile , String , String ) > , Vec < LDNError > > {
295
- //TODO: Avoid filtering by allocators. Simply get all active & merged applications from the database.
296
- let allocators = match database:: allocators:: get_allocators ( ) . await {
297
- Ok ( allocs) => allocs,
298
- Err ( e) => {
299
- return Err ( vec ! [ LDNError :: Load ( format!(
300
- "Failed to retrieve allocators: {}" ,
301
- e
302
- ) ) ] )
303
- }
304
- } ;
296
+ let db_apps = database:: applications:: get_applications ( ) . await ;
305
297
let mut all_apps: Vec < ( ApplicationFile , String , String ) > = Vec :: new ( ) ;
306
- let mut errors: Vec < LDNError > = Vec :: new ( ) ;
307
-
308
- for allocator in allocators {
309
- match Self :: active ( allocator. owner . clone ( ) , allocator. repo . clone ( ) , None ) . await {
310
- Ok ( apps) => {
311
- for app in apps {
312
- all_apps. push ( ( app, allocator. owner . clone ( ) , allocator. repo . clone ( ) ) ) ;
313
- }
314
- }
315
- Err ( e) => {
316
- errors. push ( e) ;
317
- eprintln ! (
318
- "Failed to process active applications for allocator {}:{}" ,
319
- allocator. repo, allocator. owner
320
- ) ;
321
- }
322
- }
323
-
324
- match Self :: merged ( allocator. owner . clone ( ) , allocator. repo . clone ( ) ) . await {
325
- Ok ( merged_apps) => {
326
- for ( _, app) in merged_apps {
327
- all_apps. push ( ( app, allocator. owner . clone ( ) , allocator. repo . clone ( ) ) ) ;
328
- }
329
- }
330
- Err ( e) => {
331
- errors. push ( e) ;
332
- eprintln ! (
333
- "Failed to process merged applications for allocator {}:{}" ,
334
- allocator. repo, allocator. owner
335
- ) ;
298
+ match db_apps {
299
+ Ok ( apps) => {
300
+ for app in apps {
301
+ let app_file = match ApplicationFile :: from_str ( & app. application . unwrap ( ) ) {
302
+ Ok ( app) => app,
303
+ Err ( _) => {
304
+ continue ;
305
+ }
306
+ } ;
307
+ all_apps. push ( ( app_file, app. owner , app. repo ) ) ;
336
308
}
337
- }
309
+ return Ok ( all_apps) ;
310
+ } ,
311
+ Err ( e) => {
312
+ return Err ( vec ! [ LDNError :: Load ( format!( "Failed to retrieve applications from the database /// {}" , e) ) ] ) ;
313
+ } ,
338
314
}
339
315
340
- if errors. is_empty ( ) {
341
- Ok ( all_apps)
342
- } else {
343
- Err ( errors)
344
- }
345
316
}
346
317
347
318
pub async fn active ( owner : String , repo : String , filter : Option < String > ) -> Result < Vec < ApplicationFile > , LDNError > {
348
319
// Get all active applications from the database.
349
- let active_apps_result = database:: applications:: get_active_applications ( owner, repo) . await ;
320
+ let active_apps_result = database:: applications:: get_active_applications ( Some ( owner) , Some ( repo) ) . await ;
350
321
351
322
// Handle errors in getting active applications.
352
323
let active_apps = match active_apps_result {
@@ -368,7 +339,8 @@ impl LDNApplication {
368
339
if let Some ( app_json) = app_model. application {
369
340
match from_str :: < ApplicationFile > ( & app_json) {
370
341
Ok ( app) => apps. push ( app) ,
371
- Err ( e) => return Err ( LDNError :: Load ( format ! ( "Failed to parse application file: {}" , e) ) ) ,
342
+ //if error, don't push into apps
343
+ Err ( _) => { }
372
344
}
373
345
}
374
346
}
@@ -1014,7 +986,7 @@ impl LDNApplication {
1014
986
1015
987
pub async fn merged ( owner : String , repo : String ) -> Result < Vec < ( ApplicationGithubInfo , ApplicationFile ) > , LDNError > {
1016
988
// Retrieve all applications in the main branch from the database.
1017
- let merged_apps_result = database:: applications:: get_merged_applications ( owner. clone ( ) , repo. clone ( ) ) . await ;
989
+ let merged_apps_result = database:: applications:: get_merged_applications ( Some ( owner. clone ( ) ) , Some ( repo. clone ( ) ) ) . await ;
1018
990
1019
991
// Handle errors in getting applications from the main branch.
1020
992
let merged_app_models = match merged_apps_result {
@@ -1030,7 +1002,7 @@ impl LDNApplication {
1030
1002
if let Some ( app_json) = app_model. application {
1031
1003
match from_str :: < ApplicationFile > ( & app_json) {
1032
1004
Ok ( app) => merged_apps. push ( ( ApplicationGithubInfo { sha : app_model. sha . unwrap ( ) , path : app_model. path . unwrap ( ) } , app) ) ,
1033
- Err ( e ) => return Err ( LDNError :: Load ( format ! ( "Failed to parse application file: {}" , e ) ) ) ,
1005
+ Err ( _ ) => { } ,
1034
1006
}
1035
1007
}
1036
1008
}
@@ -1952,7 +1924,7 @@ Your Datacap Allocation Request has been {} by the Notary
1952
1924
1953
1925
pub async fn cache_renewal_active ( owner : String , repo : String ) -> Result < ( ) , LDNError > {
1954
1926
let active_from_gh: Vec < ApplicationFileWithDate > = LDNApplication :: active_apps_with_last_update ( owner. clone ( ) , repo. clone ( ) , None ) . await ?;
1955
- let active_from_db: Vec < ApplicationModel > = database:: applications:: get_active_applications ( owner. clone ( ) , repo. clone ( ) ) . await . unwrap ( ) ;
1927
+ let active_from_db: Vec < ApplicationModel > = database:: applications:: get_active_applications ( Some ( owner. clone ( ) ) , Some ( repo. clone ( ) ) ) . await . unwrap ( ) ;
1956
1928
1957
1929
let mut db_apps_set: HashSet < String > = HashSet :: new ( ) ;
1958
1930
let mut processed_gh_apps: HashSet < String > = HashSet :: new ( ) ;
@@ -2009,7 +1981,7 @@ Your Datacap Allocation Request has been {} by the Notary
2009
1981
2010
1982
pub async fn cache_renewal_merged ( owner : String , repo : String ) -> Result < ( ) , LDNError > {
2011
1983
let merged_from_gh: Vec < ApplicationFileWithDate > = LDNApplication :: merged_apps_with_last_update ( owner. clone ( ) , repo. clone ( ) , None ) . await ?;
2012
- let merged_from_db: Vec < ApplicationModel > = database:: applications:: get_merged_applications ( owner. clone ( ) , repo. clone ( ) ) . await . unwrap ( ) ;
1984
+ let merged_from_db: Vec < ApplicationModel > = database:: applications:: get_merged_applications ( Some ( owner. clone ( ) ) , Some ( repo. clone ( ) ) ) . await . unwrap ( ) ;
2013
1985
2014
1986
let mut db_apps_set: HashSet < String > = HashSet :: new ( ) ;
2015
1987
let mut processed_gh_apps: HashSet < String > = HashSet :: new ( ) ;
0 commit comments