Skip to content

Commit 07fe581

Browse files
authored
fix: b8 broken api endpoints and logging (AscensionGameDev#2126)
* Fix metrics endpoint from sending the jsob of a http response message instead of actual metric data. * Fix logging db records not saving. Not sure why this worked back in .net 4 and not now but we need to explicitly call .SaveChanges on the logging context
1 parent 9081319 commit 07fe581

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

Intersect.Server.Core/Database/Logging/Entities/ChatHistory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ public static void LogMessage(Player player, string message, ChatMessageType typ
6868

6969
private static void Log(ChatHistory chatHistory)
7070
{
71-
using var loggingContext = DbInterface.CreateLoggingContext(readOnly: false);
72-
_ = loggingContext.ChatHistory.Add(chatHistory);
71+
using (var loggingContext = DbInterface.CreateLoggingContext(readOnly: false))
72+
{
73+
loggingContext.ChatHistory.Add(chatHistory);
74+
loggingContext.SaveChanges();
75+
}
7376
}
7477
}
7578
}

Intersect.Server.Core/Database/Logging/Entities/GuildHistory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ public static void LogActivity(Guid guildId, Guid userId, Guid playerId, string
104104

105105
private static void Log(GuildHistory guildHistory)
106106
{
107-
using var loggingContext = DbInterface.CreateLoggingContext(readOnly: false);
108-
_ = loggingContext.GuildHistory.Add(guildHistory);
107+
using (var loggingContext = DbInterface.CreateLoggingContext(readOnly: false))
108+
{
109+
loggingContext.GuildHistory.Add(guildHistory);
110+
loggingContext.SaveChanges();
111+
}
109112
}
110113
}
111114
}

Intersect.Server.Core/Database/Logging/Entities/TradeHistory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ public static void LogTrade(Guid tradeId, Player player, Player target, Item[] o
9999

100100
private static void Log(TradeHistory tradeHistory)
101101
{
102-
using var loggingContext = DbInterface.CreateLoggingContext(readOnly: false);
103-
_ = loggingContext.TradeHistory.Add(tradeHistory);
102+
using (var loggingContext = DbInterface.CreateLoggingContext(readOnly: false))
103+
{
104+
loggingContext.TradeHistory.Add(tradeHistory);
105+
loggingContext.SaveChanges();
106+
}
104107
}
105108
}
106109
}

Intersect.Server.Core/Database/Logging/Entities/UserActivityHistory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ public static void LogActivity(Guid userId, Guid playerId, string ip, PeerType p
129129

130130
private static void Log(UserActivityHistory userActivityHistory)
131131
{
132-
using var loggingContext = DbInterface.CreateLoggingContext(readOnly: false);
133-
_ = loggingContext.UserActivityHistory.Add(userActivityHistory);
132+
using (var loggingContext = DbInterface.CreateLoggingContext(readOnly: false))
133+
{
134+
loggingContext.UserActivityHistory.Add(userActivityHistory);
135+
loggingContext.SaveChanges();
136+
}
134137
}
135138
}
136139
}

Intersect.Server/Web/RestApi/Routes/V1/InfoController.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ public object Stats()
5656
}
5757

5858
[HttpGet("metrics")]
59+
[Produces("application/json")]
5960
public object StatsMetrics()
6061
{
61-
return new HttpResponseMessage()
62-
{
63-
Content = new StringContent(MetricsRoot.Instance.Metrics, System.Text.Encoding.UTF8, "application/json")
64-
};
62+
return Ok(MetricsRoot.Instance.Metrics );
6563
}
6664
}
6765
}

0 commit comments

Comments
 (0)