Skip to content

Conversation

@ken-zlai
Copy link
Contributor

@ken-zlai ken-zlai commented Jan 21, 2025

Summary

Switched over to using layerstack format function. This should preserve functionality (and treat dates in job tracker "as is" without converting for timezone.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • Changes in Date Formatting

    • Removed formatDate function from multiple components.
    • Updated date formatting approach to utilize a new utility function for consistency.
    • Simplified date display logic, enhancing clarity in job run information.
  • Impact on User Experience

    • Date representations may appear slightly different.
    • Consistent date formatting across the application.
    • Minor visual changes in job tracking and observability views.

@ken-zlai ken-zlai requested a review from sean-zlai January 21, 2025 18:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Walkthrough

The pull request modifies date formatting across several frontend files. It removes the formatDate function from component props, updates the implementation of date formatting in utility functions, and utilizes the @layerstack/utils package for consistent date representation. These changes streamline date handling while ensuring a uniform approach to date formatting throughout the application.

Changes

File Change Summary
frontend/src/lib/components/JobOverviewChart.svelte Removed formatDate from destructured props
frontend/src/lib/util/format.ts Simplified formatDate function, broadened input types, removed includeTime parameter
frontend/src/routes/joins/[slug]/job-tracking/+page.svelte Updated date formatting, removed formatDate prop from JobOverviewChart
frontend/src/routes/joins/[slug]/observability/drift/+page.svelte Replaced local date formatting with formatDate function

Possibly related PRs

Suggested reviewers

  • piyush-zlai

Poem

🕰️ Dates dancing, format refined
Code trimmed, utility aligned
Layers of time, now crystal clear
Formatting magic, drawing near!
A symphony of timestamps bright 🌟

Warning

Review ran into problems

🔥 Problems

GitHub Actions: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.


if (includeTime) {
Object.assign(options, {
export function formatDate(value: string | number): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

In my ECharts => LayerChart PR I also updated formatDate() to take in a Date | null | undefined along with string | number. Would you want to include that in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks good. I brought in the null | undefined, added a check for undefined, and also brought in your code which checks if it is a date before converting.

I think this should cover our bases

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between b27d34e and f75cba0.

📒 Files selected for processing (4)
  • frontend/src/lib/components/JobOverviewChart.svelte (1 hunks)
  • frontend/src/lib/util/format.ts (1 hunks)
  • frontend/src/routes/joins/[slug]/job-tracking/+page.svelte (3 hunks)
  • frontend/src/routes/joins/[slug]/observability/drift/+page.svelte (1 hunks)
🔇 Additional comments (4)
frontend/src/lib/components/JobOverviewChart.svelte (1)

8-11: LGTM! Props cleanup.

Clean removal of formatDate from props.

frontend/src/routes/joins/[slug]/job-tracking/+page.svelte (2)

68-76: LGTM! Consistent date formatting.

Clean implementation using layerstack format.


191-191: LGTM! Props update.

Correctly removed formatDate prop.

frontend/src/routes/joins/[slug]/observability/drift/+page.svelte (1)

172-172: LGTM! Consistent date formatting.

Using centralized formatDate utility.

Comment on lines 1 to 19
import { format, PeriodType } from '@layerstack/utils';

/**
* Formats a timestamp into a human-readable date string
* Formats a timestamp into a human-readable date string.
* For example: Dec 31, 2022, 5:00:00 PM
*/
export function formatDate(value: string | number, includeTime: boolean = true): string {
const options: Intl.DateTimeFormatOptions = {
month: 'short',
day: 'numeric',
year: 'numeric'
};

if (includeTime) {
Object.assign(options, {
export function formatDate(value: string | number): string {
return format(new Date(value), PeriodType.Custom, {
custom: {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: '2-digit',
second: '2-digit',
hour12: true
});
}

return new Date(value).toLocaleString('en-US', options);
}
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Lock @layerstack/utils version

Using ^0.0.7 allows minor updates which can break in 0.x versions. Consider exact version 0.0.7.

🔗 Analysis chain

LGTM! Verify @layerstack/utils version.

The new implementation provides consistent date formatting.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check @layerstack/utils version
jq -r '.dependencies["@layerstack/utils"]' package.json

Length of output: 128


Script:

#!/bin/bash
# Find package.json files and check for @layerstack/utils
fd package.json --type f --exec sh -c 'echo "=== {} ==="; cat {} | grep -A1 "@layerstack/utils" || true'

Length of output: 202

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/lib/util/format.ts (1)

4-7: Add null behavior to docs.

Add example of null/undefined return value.

 /**
  * Formats a timestamp into a human-readable date string.
  * For example: Dec 31, 2022, 5:00:00 PM
+ * Returns empty string for null/undefined values.
  */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between f75cba0 and 43cbca0.

📒 Files selected for processing (1)
  • frontend/src/lib/util/format.ts (1 hunks)
🔇 Additional comments (1)
frontend/src/lib/util/format.ts (1)

1-1: Lock @layerstack/utils version.

Using ^0.0.7 allows minor updates which can break in 0.x versions.

@ken-zlai ken-zlai merged commit ab97dc4 into main Jan 21, 2025
4 checks passed
@ken-zlai ken-zlai deleted the ken/layerstack-format branch January 21, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants