Skip to content

Commit 816d70a

Browse files
committed
Sorted activities by timestamp_started
1 parent 2272b8c commit 816d70a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/lib/common/task_utilities.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Sort task-group activities by timestamp_started.
3+
* @param {import('$lib/types-v2').TaskGroupActivityV2} a1
4+
* @param {import('$lib/types-v2').TaskGroupActivityV2} a2
5+
*/
6+
export const sortActivitiesByTimestampStarted = function (a1, a2) {
7+
return a1.timestamp_started < a2.timestamp_started ? 1 : -1;
8+
};

src/lib/components/v2/tasks/TaskCollection.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
getTaskActivityStatusBadgeClass,
1010
getTaskGroupActivitiesToUpdate
1111
} from './task_group_utilities';
12+
import { sortActivitiesByTimestampStarted } from '$lib/common/task_utilities';
1213
1314
// This component automatically fecthes updates for task collections activities
1415
// in pending and ongoing status
1516
1617
/** @type {import('$lib/types-v2').TaskGroupActivityV2[]} */
1718
let recentActivities = [];
1819
20+
$: sortedRecentActivities = [...recentActivities].sort(sortActivitiesByTimestampStarted);
21+
1922
/** @type {'pypi'|'local'} */
2023
export let packageType = 'pypi';
2124
/** @type {() => Promise<void>} */
@@ -413,7 +416,7 @@
413416
</tr>
414417
</thead>
415418
<tbody>
416-
{#each recentActivities as taskGroupActivity}
419+
{#each sortedRecentActivities as taskGroupActivity}
417420
<tr>
418421
<td>{taskGroupActivity.pkg_name}</td>
419422
<td>

src/lib/components/v2/tasks/TaskGroupActivities.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { getTimestamp } from '$lib/common/component_utilities';
1111
import { page } from '$app/stores';
1212
import { sortUserByEmailComparator } from '$lib/common/user_utilities';
13+
import { sortActivitiesByTimestampStarted } from '$lib/common/task_utilities';
1314
1415
export let admin = false;
1516
@@ -101,7 +102,7 @@
101102
}
102103
/** @type {import('$lib/types-v2').TaskGroupActivityV2[]} */
103104
const activities = await response.json();
104-
activities.sort((a1, a2) => (a1.timestamp_started < a2.timestamp_started ? 1 : -1));
105+
activities.sort(sortActivitiesByTimestampStarted);
105106
results = activities;
106107
} finally {
107108
searching = false;

0 commit comments

Comments
 (0)