@@ -513,19 +513,55 @@ impl LDNApplication {
513
513
}
514
514
515
515
pub async fn all_applications ( ) -> Result < Vec < ApplicationResponse > , LDNError > {
516
- let db_apps = database:: applications:: get_active_applications ( )
516
+ let applications = database:: applications:: get_active_applications ( )
517
517
. await
518
518
. map_err ( |e| {
519
519
LDNError :: Load ( format ! (
520
520
"Failed to get applications from the database: {}" ,
521
521
e
522
522
) )
523
523
} ) ?;
524
- let mut all_apps: Vec < ApplicationResponse > = Vec :: new ( ) ;
525
- for app in db_apps {
524
+ let applications_response = Self :: prepare_applications_response ( applications) ;
525
+ Ok ( applications_response)
526
+ }
527
+
528
+ pub async fn get_closed_applications ( ) -> Result < Vec < ApplicationResponse > , LDNError > {
529
+ let applications = database:: applications:: get_closed_applications ( )
530
+ . await
531
+ . map_err ( |e| {
532
+ LDNError :: Load ( format ! (
533
+ "Failed to get applications from the database: {}" ,
534
+ e
535
+ ) )
536
+ } ) ?;
537
+ let applications_response = Self :: prepare_applications_response ( applications) ;
538
+ Ok ( applications_response)
539
+ }
540
+
541
+ pub async fn get_allocator_closed_applications (
542
+ owner : & str ,
543
+ repo : & str ,
544
+ ) -> Result < Vec < ApplicationResponse > , LDNError > {
545
+ let applications = database:: applications:: get_allocator_closed_applications ( owner, repo)
546
+ . await
547
+ . map_err ( |e| {
548
+ LDNError :: Load ( format ! (
549
+ "Failed to get applications from the database: {}" ,
550
+ e
551
+ ) )
552
+ } ) ?;
553
+ let applications_response = Self :: prepare_applications_response ( applications) ;
554
+ Ok ( applications_response)
555
+ }
556
+
557
+ fn prepare_applications_response (
558
+ applications : Vec < ApplicationModel > ,
559
+ ) -> Vec < ApplicationResponse > {
560
+ let mut applications_response: Vec < ApplicationResponse > = Vec :: new ( ) ;
561
+ for app in applications {
526
562
if let Some ( application_data) = app. application {
527
563
if let Ok ( app_file) = ApplicationFile :: from_str ( & application_data) {
528
- all_apps . push ( ApplicationResponse {
564
+ applications_response . push ( ApplicationResponse {
529
565
file : app_file,
530
566
issue_reporter_handle : app. issue_reporter_handle ,
531
567
repo : app. repo ,
@@ -534,7 +570,7 @@ impl LDNApplication {
534
570
}
535
571
}
536
572
}
537
- Ok ( all_apps )
573
+ applications_response
538
574
}
539
575
540
576
pub async fn active (
0 commit comments