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 the inserted_at field on listens #48

Merged
merged 1 commit into from
Dec 22, 2023
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
4 changes: 2 additions & 2 deletions MetaBrainz.ListenBrainz/Interfaces/IListen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace MetaBrainz.ListenBrainz.Interfaces;
[PublicAPI]
public interface IListen : IJsonBasedObject {

/// <summary>The timestamp at which the listen information was inserted in the database, in human-readable format.</summary>
string InsertedAt { get; }
/// <summary>The timestamp at which the listen information was inserted in the database.</summary>
DateTimeOffset InsertedAt { get; }

/// <summary>The MessyBrainz ID for the recording that was listened to.</summary>
Guid MessyRecordingId { get; }
Expand Down
6 changes: 3 additions & 3 deletions MetaBrainz.ListenBrainz/Json/Readers/ListenReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class ListenReader : ObjectReader<Listen> {
public static readonly ListenReader Instance = new();

protected override Listen ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options) {
string? inserted = null;
long? inserted = null;
Guid? msid = null;
ITrackInfo? track = null;
string? user = null;
Expand All @@ -26,7 +26,7 @@ protected override Listen ReadObjectContents(ref Utf8JsonReader reader, JsonSeri
reader.Read();
switch (prop) {
case "inserted_at":
inserted = reader.GetString();
inserted = reader.GetInt64();
break;
case "listened_at":
ts = reader.GetInt64();
Expand Down Expand Up @@ -66,7 +66,7 @@ protected override Listen ReadObjectContents(ref Utf8JsonReader reader, JsonSeri
if (ts is null) {
throw new JsonException("Expected listened-at timestamp not found or null.");
}
return new Listen(inserted, msid.Value, ts.Value, track, user) {
return new Listen(inserted.Value, msid.Value, ts.Value, track, user) {
UnhandledProperties = rest
};
}
Expand Down
6 changes: 3 additions & 3 deletions MetaBrainz.ListenBrainz/Objects/Listen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ namespace MetaBrainz.ListenBrainz.Objects;
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
internal sealed class Listen : JsonBasedObject, IListen {

public Listen(string inserted, Guid msid, long timestamp, ITrackInfo track, string user) {
this.InsertedAt = inserted;
public Listen(long inserted, Guid msid, long timestamp, ITrackInfo track, string user) {
this.InsertedAt = DateTimeOffset.FromUnixTimeSeconds(inserted);
this.MessyRecordingId = msid;
this.Timestamp = DateTimeOffset.FromUnixTimeSeconds(timestamp);
this.Track = track;
this.UnixTimestamp = timestamp;
this.User = user;
}

public string InsertedAt { get; }
public DateTimeOffset InsertedAt { get; }

public Guid MessyRecordingId { get; }

Expand Down
2 changes: 1 addition & 1 deletion public-api/MetaBrainz.ListenBrainz.net6.0.cs.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public interface ILatestImport : MetaBrainz.Common.Json.IJsonBasedObject {
```cs
public interface IListen : MetaBrainz.Common.Json.IJsonBasedObject {

string InsertedAt {
System.DateTimeOffset InsertedAt {
public abstract get;
}

Expand Down
2 changes: 1 addition & 1 deletion public-api/MetaBrainz.ListenBrainz.net8.0.cs.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public interface ILatestImport : MetaBrainz.Common.Json.IJsonBasedObject {
```cs
public interface IListen : MetaBrainz.Common.Json.IJsonBasedObject {

string InsertedAt {
System.DateTimeOffset InsertedAt {
public abstract get;
}

Expand Down