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

feat:Add custom JSON converter for Unix timestamps and update TenantStats class #42

Merged
merged 1 commit into from
Aug 30, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/libs/LangSmith/Generated/JsonConverters.UnixTimestamp.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public class UnixTimestampJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::System.DateTimeOffset>
{
/// <inheritdoc />
public override global::System.DateTimeOffset Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
if (reader.TokenType == global::System.Text.Json.JsonTokenType.Number)
{
if (reader.TryGetInt64(out long unixTimestamp))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestamp);
}
if (reader.TryGetInt32(out int unixTimestampInt))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestampInt);
}
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::System.DateTimeOffset value,
global::System.Text.Json.JsonSerializerOptions options)
{
long unixTimestamp = value.ToUnixTimeSeconds();
writer.WriteNumberValue(unixTimestamp);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public sealed partial class TenantStats
[global::System.Text.Json.Serialization.JsonRequired]
public required int AnnotationQueueCount { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("deployment_count")]
[global::System.Text.Json.Serialization.JsonRequired]
public required int DeploymentCount { get; set; }
Comment on lines +46 to +51
Copy link

Choose a reason for hiding this comment

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

Review of new property DeploymentCount in TenantStats class.

The addition of the DeploymentCount property is well-integrated with the existing structure of the TenantStats class. The property is marked as required and uses the JSON property name "deployment_count", which is consistent with the naming conventions of other properties in the class.

  • Property Attributes: The use of [JsonRequired] ensures that the property must be present during deserialization, which is crucial for data integrity.
  • Documentation: The summary documentation is missing a description. It would be beneficial to add a brief description of what DeploymentCount represents for better code readability and maintenance.

Overall, the property is correctly implemented, but enhancing the documentation would improve the code quality.

Consider adding a description to the summary documentation for the DeploymentCount property to enhance clarity and maintainability.

        /// <summary>
        /// Represents the count of deployments.
        /// </summary>
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("deployment_count")]
[global::System.Text.Json.Serialization.JsonRequired]
public required int DeploymentCount { get; set; }
/// <summary>
/// Represents the count of deployments.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("deployment_count")]
[global::System.Text.Json.Serialization.JsonRequired]
public required int DeploymentCount { get; set; }


/// <summary>
///
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/libs/LangSmith/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17322,6 +17322,7 @@ components:
- tracer_session_count
- repo_count
- annotation_queue_count
- deployment_count
- dashboards_count
type: object
properties:
Expand All @@ -17341,6 +17342,9 @@ components:
annotation_queue_count:
title: Annotation Queue Count
type: integer
deployment_count:
title: Deployment Count
type: integer
dashboards_count:
title: Dashboards Count
type: integer
Expand Down