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(ingestion-ui) Sort ingestion sources by last execution time #5807

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import com.linkedin.metadata.search.SearchResult;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -66,15 +68,20 @@ public CompletableFuture<ListIngestionSourcesResult> get(final DataFetchingEnvir
new HashSet<>(gmsResult.getEntities().stream()
.map(SearchEntity::getEntity)
.collect(Collectors.toList())),
ImmutableSet.of(Constants.INGESTION_INFO_ASPECT_NAME),
ImmutableSet.of(Constants.INGESTION_INFO_ASPECT_NAME, Constants.INGESTION_SOURCE_KEY_ASPECT_NAME),
context.getAuthentication());

final Collection<EntityResponse> sortedEntities = entities.values()
.stream()
.sorted(Comparator.comparingLong(s -> -s.getAspects().get(Constants.INGESTION_SOURCE_KEY_ASPECT_NAME).getCreated().getTime()))
.collect(Collectors.toList());

// Now that we have entities we can bind this to a result.
final ListIngestionSourcesResult result = new ListIngestionSourcesResult();
result.setStart(gmsResult.getFrom());
result.setCount(gmsResult.getPageSize());
result.setTotal(gmsResult.getNumEntities());
result.setIngestionSources(IngestionResolverUtils.mapIngestionSources(entities.values()));
result.setIngestionSources(IngestionResolverUtils.mapIngestionSources(sortedEntities));
return result;

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.linkedin.entity.client.EntityClient;
import com.linkedin.ingestion.DataHubIngestionSourceInfo;
import com.linkedin.metadata.Constants;
import com.linkedin.metadata.key.DataHubIngestionSourceKey;
import com.linkedin.metadata.search.SearchEntity;
import com.linkedin.metadata.search.SearchEntityArray;
import com.linkedin.metadata.search.SearchResult;
Expand All @@ -36,6 +37,8 @@ public void testGetSuccess() throws Exception {
EntityClient mockClient = Mockito.mock(EntityClient.class);

DataHubIngestionSourceInfo returnedInfo = getTestIngestionSourceInfo();
final DataHubIngestionSourceKey key = new DataHubIngestionSourceKey();
key.setId("test");

Mockito.when(mockClient.search(
Mockito.eq(Constants.INGESTION_SOURCE_ENTITY_NAME),
Expand All @@ -55,7 +58,7 @@ public void testGetSuccess() throws Exception {
Mockito.when(mockClient.batchGetV2(
Mockito.eq(Constants.INGESTION_SOURCE_ENTITY_NAME),
Mockito.eq(new HashSet<>(ImmutableSet.of(TEST_INGESTION_SOURCE_URN))),
Mockito.eq(ImmutableSet.of(Constants.INGESTION_INFO_ASPECT_NAME)),
Mockito.eq(ImmutableSet.of(Constants.INGESTION_INFO_ASPECT_NAME, Constants.INGESTION_SOURCE_KEY_ASPECT_NAME)),
Mockito.any(Authentication.class)
)).thenReturn(
ImmutableMap.of(
Expand All @@ -65,7 +68,9 @@ public void testGetSuccess() throws Exception {
.setUrn(TEST_INGESTION_SOURCE_URN)
.setAspects(new EnvelopedAspectMap(ImmutableMap.of(
Constants.INGESTION_INFO_ASPECT_NAME,
new EnvelopedAspect().setValue(new Aspect(returnedInfo.data()))
new EnvelopedAspect().setValue(new Aspect(returnedInfo.data())),
Constants.INGESTION_SOURCE_KEY_ASPECT_NAME,
new EnvelopedAspect().setValue(new Aspect(key.data()))
)))
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ function IngestionSourceTable({
dataIndex: 'type',
key: 'type',
render: TypeColumn,
sorter: (sourceA, sourceB) => sourceA.type.localeCompare(sourceB.type),
},
{
title: 'Name',
dataIndex: 'name',
key: 'name',
render: (name: string) => name || '',
sorter: (sourceA, sourceB) => sourceA.name.localeCompare(sourceB.name),
},
{
title: 'Schedule',
Expand All @@ -67,12 +69,14 @@ function IngestionSourceTable({
dataIndex: 'execCount',
key: 'execCount',
render: (execCount: any) => <Typography.Text>{execCount || '0'}</Typography.Text>,
sorter: (sourceA, sourceB) => sourceA.execCount - sourceB.execCount,
},
{
title: 'Last Execution',
dataIndex: 'lastExecTime',
key: 'lastExecTime',
render: LastExecutionColumn,
sorter: (sourceA, sourceB) => sourceA.lastExecTime - sourceB.lastExecTime,
},
{
title: 'Last Status',
Expand All @@ -81,6 +85,7 @@ function IngestionSourceTable({
render: (status: any, record) => (
<LastStatusColumn status={status} record={record} setFocusExecutionUrn={setFocusExecutionUrn} />
),
sorter: (sourceA, sourceB) => (sourceA.lastExecStatus || '').localeCompare(sourceB.lastExecStatus || ''),
},
{
title: '',
Expand Down