Skip to content

Commit 100a849

Browse files
strahervagg
authored andcommitted
Add pagination to ClusterTaskHistory (#617)
* Add pagination to cluster task history * Remove task history limit/offset defaults
1 parent 2629f7b commit 100a849

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

web/api/webrpc/cluster.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ type TaskHistorySummary struct {
103103
CompletedBy string
104104
}
105105

106-
func (a *WebRPC) ClusterTaskHistory(ctx context.Context) ([]TaskHistorySummary, error) {
107-
limit := len(a.taskSPIDs)
108-
rows, err := a.deps.DB.Query(ctx, "SELECT id, name, task_id, posted, work_start, work_end, result, err, completed_by_host_and_port FROM harmony_task_history ORDER BY work_end DESC LIMIT $1", limit)
106+
func (a *WebRPC) ClusterTaskHistory(ctx context.Context, limit, offset int) ([]TaskHistorySummary, error) {
107+
rows, err := a.deps.DB.Query(ctx, "SELECT id, name, task_id, posted, work_start, work_end, result, err, completed_by_host_and_port FROM harmony_task_history ORDER BY work_end DESC LIMIT $1 OFFSET $2", limit, offset)
109108
if err != nil {
110109
return nil, err // Handle error
111110
}

web/static/cluster-task-history.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ customElements.define('cluster-task-history', class ClusterTaskHistory extends L
88
this.loadData();
99
}
1010
async loadData() {
11-
this.data = await RPCCall('ClusterTaskHistory');
11+
this.data = await RPCCall('ClusterTaskHistory', [20, 0]);
1212
setTimeout(() => this.loadData(), 2000);
1313
this.requestUpdate();
1414
}

0 commit comments

Comments
 (0)