Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(taskView): Implement opt-in paginated request for TaskView (backport #10093) #10096

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export interface ISpinnakerSettings {
};
stashTriggerInfo?: string;
pollSchedule: number;
tasksViewLimitPerPage: number;
providers?: {
[key: string]: IProviderSettings; // allows custom providers not typed in here (good for testing too)
};
Expand Down
20 changes: 18 additions & 2 deletions packages/core/src/task/task.dataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as angular from 'angular';

import { ApplicationDataSourceRegistry } from '../application/service/ApplicationDataSourceRegistry';
import { CLUSTER_SERVICE } from '../cluster/cluster.service';
import { SETTINGS } from '../config';
import { TaskReader } from './task.read.service';

export const CORE_TASK_TASK_DATASOURCE = 'spinnaker.core.task.dataSource';
Expand All @@ -14,8 +15,23 @@ angular.module(CORE_TASK_TASK_DATASOURCE, [CLUSTER_SERVICE]).run([
return $q.when(angular.isArray(tasks) ? tasks : []);
};

const loadTasks = (application) => {
return TaskReader.getTasks(application.name);
const loadPaginatedTasks = async (application, page = 1) => {
let limitPerPage = SETTINGS.tasksViewLimitPerPage;
const tasks = await TaskReader.getTasks(application.name, [], limitPerPage, page);
if (tasks.length === limitPerPage) {
return tasks.concat(await loadPaginatedTasks(application, page + 1));
} else {
return tasks;
}
};

const loadTasks = (application, page = 1) => {
let limitPerPage = SETTINGS.tasksViewLimitPerPage;
if (limitPerPage === undefined) {
return TaskReader.getTasks(application.name);
} else {
return loadPaginatedTasks(application, page);
}
};

const loadRunningTasks = (application) => {
Expand Down
13 changes: 11 additions & 2 deletions packages/core/src/task/task.read.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ import { OrchestratedItemTransformer } from '../orchestratedItem/orchestratedIte
export class TaskReader {
private static activeStatuses: string[] = ['RUNNING', 'SUSPENDED', 'NOT_STARTED'];

public static getTasks(applicationName: string, statuses: string[] = []): PromiseLike<ITask[]> {
public static getTasks(
applicationName: string,
statuses: string[] = [],
limitPerPage: number = null,
page: number = null,
): PromiseLike<ITask[]> {
return REST('/applications')
.path(applicationName, 'tasks')
.query({ statuses: statuses.join(',') })
.query({
statuses: statuses.join(','),
limit: limitPerPage,
page: page,
})
.get()
.then((tasks: ITask[]) => {
tasks.forEach((task) => this.setTaskProperties(task));
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18292,10 +18292,10 @@ vite-plugin-svgr@^0.3.0:
dependencies:
"@svgr/core" "^5.5.0"

[email protected].16:
version "2.9.16"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.16.tgz#daf7ba50f5cc37a7bf51b118ba06bc36e97898e9"
integrity sha512-X+6q8KPyeuBvTQV8AVSnKDvXoBMnTx8zxh54sOwmmuOdxkjMmEJXH2UEchA+vTMps1xw9vL64uwJOWryULg7nA==
[email protected].18:
version "2.9.18"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.18.tgz#74e2a83b29da81e602dac4c293312cc575f091c7"
integrity sha512-sAOqI5wNM9QvSEE70W3UGMdT8cyEn0+PmJMTFvTB8wB0YbYUWw3gUbY62AOyrXosGieF2htmeLATvNxpv/zNyQ==
dependencies:
esbuild "^0.14.27"
postcss "^8.4.13"
Expand Down