@@ -1681,7 +1681,7 @@ impl LDNApplication {
1681
1681
let clompleted_application = app_file. reached_total_datacap ( ) ;
1682
1682
let parsed_app_file = serde_json:: to_string_pretty ( & clompleted_application)
1683
1683
. map_err ( |e| LDNError :: Load ( format ! ( "Failed to pare into string: {}" , e) ) ) ?;
1684
- LDNPullRequest :: create_pr_for_existing_application (
1684
+ let pr_number = LDNPullRequest :: create_pr_for_existing_application (
1685
1685
clompleted_application. id . clone ( ) ,
1686
1686
parsed_app_file,
1687
1687
self . file_name . clone ( ) ,
@@ -1694,6 +1694,28 @@ impl LDNApplication {
1694
1694
format ! ( "Total Datacap reached for {}" , clompleted_application. id) ,
1695
1695
)
1696
1696
. await ?;
1697
+
1698
+ let gh = github_async_new ( self . github . owner . clone ( ) , self . github . repo . clone ( ) ) . await ?;
1699
+
1700
+ gh. merge_pull_request ( pr_number) . await . map_err ( |e| {
1701
+ LDNError :: Load ( format ! (
1702
+ "Failed to merge pull request {}. Reason: {}" ,
1703
+ pr_number, e
1704
+ ) )
1705
+ } ) ?;
1706
+
1707
+ database:: applications:: merge_application_by_pr_number (
1708
+ self . github . owner . clone ( ) ,
1709
+ self . github . repo . clone ( ) ,
1710
+ pr_number,
1711
+ )
1712
+ . await
1713
+ . map_err ( |e| {
1714
+ LDNError :: Load ( format ! (
1715
+ "Failed to update application in database. Reason: {}" ,
1716
+ e
1717
+ ) )
1718
+ } ) ?;
1697
1719
Self :: add_comment_to_issue (
1698
1720
application_model. issue_number . to_string ( ) . clone ( ) ,
1699
1721
application_model. owner . clone ( ) ,
@@ -1980,9 +2002,7 @@ impl LDNApplication {
1980
2002
1981
2003
Self :: merge_application ( pr_number, owner, repo) . await ?;
1982
2004
return Ok ( true ) ;
1983
- } else if application. lifecycle . get_state ( ) == AppState :: Declined
1984
- || application. lifecycle . get_state ( ) == AppState :: TotalDatacapReached
1985
- {
2005
+ } else if application. lifecycle . get_state ( ) == AppState :: Declined {
1986
2006
Self :: merge_application ( pr_number, owner, repo) . await ?;
1987
2007
return Ok ( true ) ;
1988
2008
}
0 commit comments