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

Fix [Model-endpoints] Time is wrong in model endpoint #1533

Merged
merged 1 commit into from
Dec 16, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Details/DetailsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const DetailsView = React.forwardRef(
stateValue === 'aborted' ? 'N/A' : 'Not yet started'
)
: selectedItem?.updated
? formatDatetime(new Date(selectedItem?.updated), 'N/A')
? formatDatetime(selectedItem?.updated, 'N/A')
: selectedItem?.spec?.model.includes(':') // 'model-key:model-tag'
? selectedItem.spec.model.replace(/^.*:/, '') // remove key
: selectedItem?.spec?.model
Expand Down
13 changes: 6 additions & 7 deletions src/components/Details/details.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const generateArtifactsContent = (
: ''
},
last_prediction: {
value: formatDatetime(new Date(selectedItem?.status?.last_request), '-')
value: formatDatetime(selectedItem?.status?.last_request, '-')
},
error_count: {
value: selectedItem?.status?.error_count ?? '-'
Expand Down Expand Up @@ -163,7 +163,7 @@ export const generateArtifactsContent = (
value: selectedItem.tree
},
updated: {
value: formatDatetime(new Date(selectedItem.updated), 'N/A')
value: formatDatetime(selectedItem.updated, 'N/A')
},
framework: {
value: detailsType === MODELS_TAB ? selectedItem.framework ?? '' : null
Expand Down Expand Up @@ -262,7 +262,7 @@ export const generateFunctionsContent = selectedItem => ({
value: selectedItem.build.code_origin ?? ''
},
updated: {
value: formatDatetime(new Date(selectedItem.updated), 'N/A')
value: formatDatetime(selectedItem.updated, 'N/A')
},
command: {
value: selectedItem.command
Expand Down Expand Up @@ -428,7 +428,7 @@ export const generateFeatureSetsOverviewContent = (
value: selectedItem.tag
},
updated: {
value: formatDatetime(new Date(selectedItem.updated), 'N/A')
value: formatDatetime(selectedItem.updated, 'N/A')
},
usage_example: {
value: selectedItem.usage_example ?? ''
Expand Down Expand Up @@ -467,7 +467,7 @@ export const generateFeatureVectorsOverviewContent = selectedItem => ({
copyToClipboard: true
},
updated: {
value: formatDatetime(new Date(selectedItem.updated), 'N/A')
value: formatDatetime(selectedItem.updated, 'N/A')
},
entities: {
value: selectedItem.index_keys?.join(', ')
Expand All @@ -486,8 +486,7 @@ export const handleFinishEdit = (
detailsTabDispatch,
detailsTabState,
setChangesData,
setChangesCounter,
changesCounter
setChangesCounter
) => {
detailsTabDispatch({
type: detailsTabActions.RESET_EDIT_MODE
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailsInfo/detailsInfo.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const generateArtifactsInfoContent = (page, pageTab, selectedItem) => {
selectedItem.size ?? '',
selectedItem.target_path,
selectedItem.tree,
formatDatetime(new Date(selectedItem.updated), 'N/A'),
formatDatetime(selectedItem.updated, 'N/A'),
page === MODELS_PAGE ? selectedItem.framework ?? '' : null,
selectedItem.labels ?? [],
selectedItem.sources
Expand Down
2 changes: 1 addition & 1 deletion src/components/Project/ProjectMonitorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const ProjectMonitorView = ({
<div className="row-value">
<span className="row-label">Created at:</span>
<span className="row-name">
{formatDatetime(new Date(project.data.metadata.created), '-')}
{formatDatetime(project.data.metadata.created, '-')}
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/elements/PreviewModal/PreviewModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const PreviewModal = ({ item }) => {
</div>
)}
<div className="item-data">
{formatDatetime(new Date(item.updated || item.date), 'N/A')}
{formatDatetime(item.updated || item.date, 'N/A')}
</div>
<div className="preview-body__download">
<Tooltip template={<TextTooltipTemplate text="Download" />}>
Expand Down
2 changes: 1 addition & 1 deletion src/elements/ProjectJobs/projectJobs.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const getJobsTableData = (jobs, projectName) => {
},
startTime: {
value: formatDatetime(
new Date(job[0].status.start_time),
job[0].status.start_time,
job[0].status.state === 'aborted' ? 'N/A' : 'Not yet started'
),
className: 'table-cell_big'
Expand Down
12 changes: 6 additions & 6 deletions src/utils/createArtifactsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const createArtifactsRowData = artifact => {
type: 'owner'
},
updated: {
value: artifact.updated ? formatDatetime(new Date(artifact.updated), 'N/A') : 'N/A',
value: formatDatetime(artifact.updated, 'N/A'),
class: 'artifacts_small'
},
buttonPopout: {
Expand Down Expand Up @@ -162,7 +162,7 @@ export const createModelsRowData = (artifact, project, showExpandButton) => {
{
id: `updated.${artifact.ui.identifierUnique}`,
header: 'Updated',
value: artifact.updated ? formatDatetime(new Date(artifact.updated), 'N/A') : 'N/A',
value: formatDatetime(artifact.updated, 'N/A'),
class: 'artifacts_small'
},
{
Expand Down Expand Up @@ -293,7 +293,7 @@ export const createFilesRowData = (artifact, project, showExpandButton) => {
{
id: `updated.${artifact.ui.identifierUnique}`,
header: 'Updated',
value: artifact.updated ? formatDatetime(new Date(artifact.updated), 'N/A') : 'N/A',
value: formatDatetime(artifact.updated, 'N/A'),
class: 'artifacts_small'
},
{
Expand Down Expand Up @@ -407,13 +407,13 @@ export const createModelEndpointsRowData = (artifact, project) => {
{
id: `firstRequest.${artifact.ui.identifierUnique}`,
header: 'Uptime',
value: formatDatetime(new Date(artifact.status?.first_request), '-'),
value: formatDatetime(artifact.status?.first_request, '-'),
class: 'artifacts_small'
},
{
id: `lastRequest.${artifact.ui.identifierUnique}`,
header: 'Last prediction',
value: formatDatetime(new Date(artifact.status?.last_request), '-'),
value: formatDatetime(artifact.status?.last_request, '-'),
class: 'artifacts_small'
},
{
Expand Down Expand Up @@ -498,7 +498,7 @@ export const createDatasetsRowData = (artifact, project, showExpandButton) => {
{
id: `updated.${artifact.ui.identifierUnique}`,
header: 'Updated',
value: artifact.updated ? formatDatetime(new Date(artifact.updated), 'N/A') : 'N/A',
value: formatDatetime(artifact.updated, 'N/A'),
class: 'artifacts_small'
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/createFeatureStoreContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export const createFeatureVectorsRowData = (featureVector, pageTab, project, sho
id: `updated.${featureVector.ui.identifierUnique}`,
header: 'Updated',
value: featureVector.updated
? formatDatetime(new Date(featureVector.updated), 'N/A')
? formatDatetime(featureVector.updated, 'N/A')
: 'N/A',
class: 'table-cell-2',
showTag: true,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/createFunctionsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const createFunctionsContent = (
showTag: true,
showStatus: true,
expandedCellContent: {
value: formatDatetime(new Date(func.updated), 'N/A'),
value: formatDatetime(func.updated, 'N/A'),
class: 'functions_medium',
type: 'date',
showTag: true,
Expand All @@ -71,7 +71,7 @@ const createFunctionsContent = (
},
{
id: `updated.${func.ui.identifierUnique}`,
value: formatDatetime(new Date(func.updated), 'N/A'),
value: formatDatetime(func.updated, 'N/A'),
class: 'functions_medium',
type: 'date',
showTag: true,
Expand Down Expand Up @@ -106,7 +106,7 @@ const createFunctionsContent = (
},
updated: {
id: `updated.${func.ui.identifierUnique}`,
value: formatDatetime(new Date(func.updated), 'N/A'),
value: formatDatetime(func.updated, 'N/A'),
class: 'functions_small',
type: 'date',
showTag: true,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/createJobsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ export const createJobsWorkflowsTabContent = (
{
header: 'Created at',
id: `createdAt.${identifierUnique}`,
value: formatDatetime(new Date(job.created_at), 'N/A'),
value: formatDatetime(job.created_at, 'N/A'),
class: 'table-cell-1',
hidden: isSelectedItem
},
{
header: 'Finished at',
id: `finishedAt.${identifierUnique}`,
value: formatDatetime(new Date(job.finished_at), 'N/A'),
value: formatDatetime(job.finished_at, 'N/A'),
class: 'table-cell-1',
hidden: isSelectedItem
},
Expand Down
4 changes: 4 additions & 0 deletions src/utils/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ such restriction.
import moment from 'moment'

export const formatDatetime = (datetime, invalidDateMessage) => {
if (!datetime) {
return invalidDateMessage
}

const date = new Date(datetime)

return typeof date !== 'object' || !(date instanceof Date) || isNaN(date)
Expand Down