Skip to content

Commit d694f57

Browse files
committed
Refactor getRecentChanges method to return total count and data array in LifecycleService; update controller to handle new response structure
1 parent e280c7f commit d694f57

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/management/lifecycle/lifecycle.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ export class LifecycleController extends AbstractController {
7474
@SearchFilterOptions() searchFilterOptions: FilterOptions,
7575
@Res() res: Response,
7676
): Promise<Response<Lifecycle[]>> {
77+
const [total, data] = await this._service.getRecentChanges(searchFilterOptions);
7778
return res.status(HttpStatus.OK).json({
7879
statusCode: HttpStatus.OK,
79-
data: await this._service.getRecentChanges(searchFilterOptions),
80+
data,
81+
total,
8082
});
8183
}
8284
}

src/management/lifecycle/lifecycle.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
500500
*/
501501
public async getRecentChanges(
502502
options?: FilterOptions,
503-
): Promise<Query<Array<Lifecycle>, Lifecycle, any, Lifecycle>[]> {
503+
): Promise<[number, Query<Array<Lifecycle>, Lifecycle, any, Lifecycle>[]]> {
504+
const total = await this.count({});
504505
const result = await this.find<Lifecycle>({}, null, {
505506
populate: 'refId',
506507
sort: {
@@ -511,6 +512,6 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
511512
limit: options?.limit || 100,
512513
});
513514

514-
return result;
515+
return [total, result];
515516
}
516517
}

0 commit comments

Comments
 (0)