Skip to content

Commit

Permalink
feat: Add LastStateChange to IntegrationJournalData to be able to…
Browse files Browse the repository at this point in the history
… track _when_ an integration did something to a journal.

ref #37
  • Loading branch information
itssimple committed Nov 5, 2024
1 parent c3eab4c commit dce1a83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System;
using System.Text.Json.Serialization;

namespace Journal_Limpet.Shared.Models.Journal
{
Expand All @@ -10,5 +11,7 @@ public class IntegrationJournalData
public int LastSentLineNumber { get; set; }
[JsonPropertyName("currentGameState")]
public EDGameState CurrentGameState { get; set; }
[JsonPropertyName("lastStateChange")]
public DateTimeOffset? LastStateChange { get; set; }
}
}
2 changes: 2 additions & 0 deletions Journal-Limpet/Jobs/SharedCode/GameStateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static IntegrationJournalData GetIntegrationJournalData(UserJournal journ

public async static Task<bool> UpdateJournalIntegrationDataAsync(MSSQLDB db, long journalId, string integrationKey, IntegrationJournalData integrationJournalData)
{
integrationJournalData.LastStateChange = DateTimeOffset.UtcNow;

return (await db.ExecuteNonQueryAsync(
"UPDATE user_journal SET integration_data = JSON_MODIFY(ISNULL(integration_data, JSON_QUERY('{}')), '$.\"" + integrationKey + "\"', JSON_QUERY(@integration_data)) WHERE journal_id = @journal_id",
new SqlParameter("journal_id", journalId),
Expand Down

0 comments on commit dce1a83

Please sign in to comment.