Repository navigation
Added post publish data to stats x - #23032
Conversation
ref https://linear.app/ghost/issue/PROD-665/ This helps align the Ember and React frames - not perfect, but close for now while we transition to the same app.
WalkthroughThe update to the PostAnalytics component introduces the display of a post's published date and time. The data fetching logic is modified so that the Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
apps/posts/src/views/PostAnalytics/PostAnalytics.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-react-hooks". (The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/apps/posts".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-react-hooks" was referenced from the config file in "apps/posts/.eslintrc.cjs". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (4)
16-17: Replace empty interface with type alias.The empty interface doesn't add any value and could be simplified.
-interface postAnalyticsProps {} +type PostAnalyticsProps = {};Also, consider using PascalCase for consistency with other type names in the codebase.
36-37: Consider a safer type narrowing approach.While the type assertion works, consider a more type-safe approach.
-// Type assertion for post -const typedPost = post as PostWithPublishedAt; +// Type-safe approach with narrowing +const typedPost: PostWithPublishedAt = post ? { + ...post, + published_at: post.published_at +} : undefined;
89-93: Use optional chaining for more concise code.The conditional check could be simplified using optional chaining as suggested by the static analysis.
-{typedPost && typedPost.published_at && ( +{typedPost?.published_at && ( <div className='mt-1 text-sm text-grey-600'> Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} </div> )}Also, consider respecting the user's timezone instead of using UTC for displaying dates:
-Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} +Published on your site on {moment(typedPost.published_at).format('D MMM YYYY')} at {moment(typedPost.published_at).format('HH:mm')}Alternatively, if UTC display is intentional, clarify this in the text:
-Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} +Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')} UTC🧰 Tools
🪛 Biome (1.9.4)
[error] 89-89: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
22-22: Update component type to use PascalCase props type.For consistency with TypeScript naming conventions, update the component definition.
-const PostAnalytics: React.FC<postAnalyticsProps> = () => { +const PostAnalytics: React.FC<PostAnalyticsProps> = () => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (1)
apps/admin-x-framework/src/api/posts.ts (1)
Post(3-8)
🪛 Biome (1.9.4)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx
[error] 15-16: An empty interface is equivalent to {}.
Safe fix: Use a type alias instead.
(lint/suspicious/noEmptyInterface)
[error] 89-89: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Unit tests (Node 22.13.1)
- GitHub Check: Unit tests (Node 20.11.1)
- GitHub Check: Unit tests (Node 18.12.1)
- GitHub Check: Lint
🔇 Additional comments (3)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (3)
8-8: Good addition of the moment-timezone library.The import is appropriately added to support the new functionality for displaying formatted publication dates.
18-20: Good interface extension approach.The extension of the
Posttype is well-implemented, withpublished_atcorrectly marked as optional for backward compatibility.
32-32: Correct field addition to fetch published_at data.Appropriate update to the fields parameter to include the newly required
published_atfield.
ref https://linear.app/ghost/issue/PROD-665/
This helps align the Ember and React frames - not perfect, but close for now while we transition to the same app.