Skip to content

Commit 843666f

Browse files
authored
[Feature] - Add lastDeployedAt date to application object (#6753)
* -add lastDeployedAt date to application object * -skip setting published date when application is forked
1 parent a5ec0ad commit 843666f

File tree

9 files changed

+29
-16
lines changed

9 files changed

+29
-16
lines changed

app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApplicationController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public Mono<ResponseDTO<Application>> create(@Valid @RequestBody Application res
7878

7979
@PostMapping("/publish/{applicationId}")
8080
public Mono<ResponseDTO<Boolean>> publish(@PathVariable String applicationId) {
81-
return applicationPageService.publish(applicationId)
81+
return applicationPageService.publish(applicationId, true)
8282
.flatMap(application ->
8383
// This event should parallel a similar event sent from the client, so we want it to be sent by the
8484
// controller and not the service method.

app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515

1616
import javax.validation.constraints.NotNull;
1717
import java.io.Serializable;
18+
import java.time.Instant;
1819
import java.util.ArrayList;
1920
import java.util.List;
2021

22+
import static com.appsmith.server.helpers.DateUtils.ISO_FORMATTER;
23+
2124
@Getter
2225
@Setter
2326
@ToString
@@ -64,6 +67,16 @@ public class Application extends BaseDomain {
6467

6568
Boolean forkingEnabled;
6669

70+
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
71+
Instant lastDeployedAt; // when this application was last deployed
72+
73+
public String getLastDeployedAt() {
74+
if(lastDeployedAt != null) {
75+
return ISO_FORMATTER.format(lastDeployedAt);
76+
}
77+
return null;
78+
}
79+
6780
// This constructor is used during clone application. It only deeply copies selected fields. The rest are either
6881
// initialized newly or is left up to the calling function to set.
6982
public Application(Application application) {

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public interface ApplicationPageService {
3434

3535
Mono<PageDTO> deleteUnpublishedPage(String id);
3636

37-
Mono<Application> publish(String applicationId);
37+
Mono<Application> publish(String applicationId, boolean isPublishedManually);
3838

3939
void generateAndSetPagePolicies(Application application, PageDTO page);
4040

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public Mono<Application> createApplication(Application application, String orgId
272272
.flatMap(savedPage -> addPageToApplication(savedApplication, savedPage, true))
273273
// Now publish this newly created app with default states so that
274274
// launching of newly created application is possible.
275-
.flatMap(updatedApplication -> publish(savedApplication.getId())
275+
.flatMap(updatedApplication -> publish(savedApplication.getId(), false)
276276
.then(applicationService.findById(savedApplication.getId(), READ_APPLICATIONS)));
277277
});
278278
}
@@ -577,7 +577,7 @@ public Mono<PageDTO> deleteUnpublishedPage(String id) {
577577
* @return Publishes a Boolean true, when the application has been published.
578578
*/
579579
@Override
580-
public Mono<Application> publish(String applicationId) {
580+
public Mono<Application> publish(String applicationId, boolean isPublishedManually) {
581581
Mono<Application> applicationMono = applicationService.findById(applicationId, MANAGE_APPLICATIONS)
582582
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId)))
583583
.cache();
@@ -623,7 +623,9 @@ public Mono<Application> publish(String applicationId) {
623623
application.setPublishedPages(pages);
624624

625625
application.setPublishedAppLayout(application.getUnpublishedAppLayout());
626-
626+
if(isPublishedManually) {
627+
application.setLastDeployedAt(Instant.now());
628+
}
627629
// Archive the deleted pages and save the application changes and then return the pages so that
628630
// the pages can also be published
629631
return Mono.zip(archivePageListMono, applicationService.save(application))

app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ExamplesOrganizationCloner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public Mono<List<String>> cloneApplications(
271271
// view mode for the newly created user.
272272
.then(Mono.just(newApplicationIds))
273273
.flatMapMany(Flux::fromIterable)
274-
.flatMap(appId -> applicationPageService.publish(appId).thenReturn(appId))
274+
.flatMap(appId -> applicationPageService.publish(appId, false).thenReturn(appId))
275275
.collectList();
276276
}
277277

app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ public void checkActionInViewMode() {
732732
Mono<List<ActionViewDTO>> actionsListMono = layoutActionService.createAction(action)
733733
.then(layoutActionService.createAction(action1))
734734
.then(layoutActionService.createAction(action2))
735-
.then(applicationPageService.publish(testPage.getApplicationId()))
735+
.then(applicationPageService.publish(testPage.getApplicationId(), true))
736736
.then(newActionService.getActionsForViewMode(testApp.getId()).collectList());
737737

738738
StepVerifier
@@ -843,7 +843,7 @@ public void getActionInViewMode() {
843843
Mono<ActionDTO> createActionMono = layoutActionService.createAction(action);
844844
Mono<List<ActionViewDTO>> actionViewModeListMono = createActionMono
845845
// Publish the application before fetching the action in view mode
846-
.then(applicationPageService.publish(testApp.getId()))
846+
.then(applicationPageService.publish(testApp.getId(), true))
847847
.then(newActionService.getActionsForViewMode(testApp.getId()).collectList());
848848

849849
StepVerifier.create(actionViewModeListMono)

app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ public void basicPublishApplicationTest() {
729729
testApplication.setName(appName);
730730
testApplication.setAppLayout(new Application.AppLayout(Application.AppLayout.Type.DESKTOP));
731731
Mono<Application> applicationMono = applicationPageService.createApplication(testApplication, orgId)
732-
.flatMap(application -> applicationPageService.publish(application.getId()))
732+
.flatMap(application -> applicationPageService.publish(application.getId(), true))
733733
.then(applicationService.findByName(appName, MANAGE_APPLICATIONS))
734734
.cache();
735735

@@ -780,7 +780,7 @@ public void deleteUnpublishedPageFromApplication() {
780780
page.setLayouts(layouts);
781781
return applicationPageService.createPage(page);
782782
})
783-
.flatMap(page -> applicationPageService.publish(page.getApplicationId()))
783+
.flatMap(page -> applicationPageService.publish(page.getApplicationId(), true))
784784
.then(applicationService.findByName(appName, MANAGE_APPLICATIONS))
785785
.cache();
786786

@@ -826,7 +826,7 @@ public void changeDefaultPageForAPublishedApplication() {
826826
page.setLayouts(layouts);
827827
return applicationPageService.createPage(page);
828828
})
829-
.flatMap(page -> applicationPageService.publish(page.getApplicationId()))
829+
.flatMap(page -> applicationPageService.publish(page.getApplicationId(), true))
830830
.then(applicationService.findByName(appName, MANAGE_APPLICATIONS))
831831
.cache();
832832

@@ -890,7 +890,7 @@ public void getApplicationInViewMode() {
890890
page.setLayouts(layouts);
891891
return applicationPageService.createPage(page);
892892
})
893-
.flatMap(page -> applicationPageService.publish(page.getApplicationId()))
893+
.flatMap(page -> applicationPageService.publish(page.getApplicationId(), true))
894894
.then(applicationService.findByName(appName, MANAGE_APPLICATIONS))
895895
.cache();
896896

app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public void refactorActionNameToDeletedName() {
295295
layout.setDsl(layoutActionService.unescapeMongoSpecialCharacters(layout));
296296
LayoutDTO firstLayout = layoutActionService.updateLayout(testPage.getId(), layout.getId(), layout).block();
297297

298-
applicationPageService.publish(testPage.getApplicationId()).block();
298+
applicationPageService.publish(testPage.getApplicationId(), true).block();
299299

300300
newActionService.deleteUnpublishedAction(firstAction.getId()).block();
301301

app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.appsmith.server.domains.NewAction;
1111
import com.appsmith.server.domains.Plugin;
1212
import com.appsmith.server.domains.User;
13-
import com.appsmith.server.domains.ApplicationPage;
1413
import com.appsmith.server.dtos.ActionDTO;
1514
import com.appsmith.server.dtos.ApplicationPagesDTO;
1615
import com.appsmith.server.dtos.LayoutDTO;
@@ -47,7 +46,6 @@
4746
import java.util.Map;
4847
import java.util.Set;
4948
import java.util.UUID;
50-
import java.util.stream.Collectors;
5149

5250
import static com.appsmith.server.acl.AclPermission.MANAGE_PAGES;
5351
import static com.appsmith.server.acl.AclPermission.READ_ACTIONS;
@@ -362,7 +360,7 @@ public void reuseDeletedPageName() {
362360
PageDTO firstPage = applicationPageService.createPage(testPage).block();
363361

364362
// Publish the application
365-
applicationPageService.publish(application.getId());
363+
applicationPageService.publish(application.getId(), true);
366364

367365
//Delete Page in edit mode
368366
applicationPageService.deleteUnpublishedPage(firstPage.getId()).block();

0 commit comments

Comments
 (0)