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: make the lastUpdatedDate consistent on LPR #1385

Merged
merged 1 commit into from
Jan 27, 2025
Merged
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
8 changes: 3 additions & 5 deletions src/components/AdvanceAnalyticsV2/AnalyticsV2Page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Skills from './tabs/Skills';
import { useEnterpriseAnalyticsAggregatesData } from './data/hooks';
import { GRANULARITY, CALCULATION, ANALYTICS_WARNING_BANNER_COOKIE } from './data/constants';
import WarningBanner from './WarningBanner';
import { formatTimestamp } from '../../utils';

const PAGE_TITLE = 'Analytics';

Expand All @@ -35,10 +36,7 @@ const AnalyticsV2Page = ({ enterpriseId }) => {
});
const showWarningBanner = cookies.get(ANALYTICS_WARNING_BANNER_COOKIE);
const currentDate = new Date().toISOString().split('T')[0];
const formatDate = (dateString) => {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
};
const defaultDataUpdatedDate = new Date().toISOString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question/clarification] Can you help me understand the interaction between the existing currentDate and the added defaultDataUpdatedDate? Is it intended to continue using currentDate variable in various places throughout this component? Should we be using only one or the other, since they are largely both representing the same thing (the current timestamp)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, currentDate does not include a timestamp, which is used in other places. That's why I created a separate variable, defaultDataUpdatedDate, which includes the timestamp. Adding the timestamp ensures consistency with LPR dates. By the way, there is a very low chance that data?.lastUpdatedAt will not be provided by the backend—it is almost always present. Therefore, defaultDataUpdatedDate serves as a safety check.

return (
<>
<Helmet title={PAGE_TITLE} />
Expand All @@ -52,7 +50,7 @@ const AnalyticsV2Page = ({ enterpriseId }) => {
id="advance.analytics.data.refresh.msg"
defaultMessage="Data updated on {date}"
description="Data refresh message"
values={{ date: formatDate(data?.lastUpdatedAt || currentDate) }}
values={{ date: formatTimestamp({ timestamp: data?.lastUpdatedAt || defaultDataUpdatedDate }) }}
/>
</span>
</div>
Expand Down
Loading