-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Stream Routing indexset oldest message in index date (#20935)
* show oldest message in index date * fix lint --------- Co-authored-by: Mohamed OULD HOCINE <[email protected]>
- Loading branch information
Showing
3 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ce/src/components/streams/StreamDetails/routing-destination/IndexSetOldestMessageCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import * as React from 'react'; | ||
|
||
import { Timestamp } from 'components/common'; | ||
import type { IndexSummary } from 'stores/indexers/IndexerOverviewStore'; | ||
|
||
type Props = { | ||
index?: IndexSummary; | ||
}; | ||
|
||
const IndexSetOldestMessageCell = ({ index = null }: Props) => ( | ||
<Timestamp dateTime={index?.range?.begin} /> | ||
); | ||
|
||
export default IndexSetOldestMessageCell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import UserNotification from 'util/UserNotification'; | ||
import type FetchError from 'logic/errors/FetchError'; | ||
import fetch from 'logic/rest/FetchProvider'; | ||
import { qualifyUrl } from 'util/URLUtils'; | ||
import ApiRoutes from 'routing/ApiRoutes'; | ||
import type { IndexerOverview } from 'stores/indexers/IndexerOverviewStore'; | ||
|
||
const fetchIndexerOverview = (indexSetId: string) => fetch('GET', qualifyUrl(ApiRoutes.IndexerOverviewApiResource.list(indexSetId).url)); | ||
|
||
const useIndexerOverview = (indexSetId: string): { | ||
data: IndexerOverview, | ||
refetch: () => void, | ||
isLoading: boolean, | ||
error: FetchError, | ||
isSuccess: boolean, | ||
} => { | ||
const { data, refetch, isLoading, error, isSuccess } = useQuery<IndexerOverview, FetchError>( | ||
['indexerOverview', indexSetId, 'stats'], | ||
() => fetchIndexerOverview(indexSetId), | ||
{ | ||
onError: (errorThrown) => { | ||
UserNotification.error(`Loading indexer overview for index set failed with status: ${errorThrown}`, | ||
'Could not load indexer overview.'); | ||
}, | ||
notifyOnChangeProps: ['data', 'error'], | ||
}, | ||
); | ||
|
||
return ({ | ||
data, | ||
refetch, | ||
isLoading, | ||
error, | ||
isSuccess, | ||
}); | ||
}; | ||
|
||
export default useIndexerOverview; |