Skip to content

Commit

Permalink
Fix [Model-endpoints] Time is wrong in model endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-prokopchuk committed Dec 15, 2022
1 parent ec7ea43 commit 8405309
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
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
10 changes: 5 additions & 5 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 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
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: artifact.updated ? formatDatetime(artifact.updated, 'N/A') : '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: artifact.updated ? formatDatetime(artifact.updated, 'N/A') : '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: artifact.updated ? formatDatetime(artifact.updated, 'N/A') : '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: artifact.updated ? formatDatetime(artifact.updated, 'N/A') : '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
8 changes: 4 additions & 4 deletions src/utils/createFunctionsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const createFunctionsContent = (functions, pageTab, projectName, showExpandButto
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 @@ -70,7 +70,7 @@ const createFunctionsContent = (functions, pageTab, projectName, showExpandButto
},
{
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 All @@ -93,7 +93,7 @@ const createFunctionsContent = (functions, pageTab, projectName, showExpandButto
return `/projects/${projectName}/functions/${hash}${`/${DETAILS_OVERVIEW_TAB}`}`
},
expandedCellContent: {
value: formatDatetime(new Date(func.updated), 'N/A'),
value: formatDatetime(func.updated, 'N/A'),
class: 'functions_medium',
type: 'date',
showTag: true,
Expand All @@ -120,7 +120,7 @@ const createFunctionsContent = (functions, pageTab, projectName, showExpandButto
{
id: `updated.${func.ui.identifierUnique}`,
header: 'Updated',
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

0 comments on commit 8405309

Please sign in to comment.