From 4e3da2e917667529793b87ed391f893dd741a255 Mon Sep 17 00:00:00 2001 From: Jetsparrow Date: Fri, 28 Jan 2022 14:47:07 +0300 Subject: [PATCH] fixes --- JetHerald/JetHerald.csproj | 4 ++-- JetHerald/Program.cs | 4 +++- JetHerald/Services/Db.cs | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/JetHerald/JetHerald.csproj b/JetHerald/JetHerald.csproj index d81bc75..157a019 100644 --- a/JetHerald/JetHerald.csproj +++ b/JetHerald/JetHerald.csproj @@ -1,7 +1,8 @@ - + net6.0 + en @@ -12,7 +13,6 @@ - diff --git a/JetHerald/Program.cs b/JetHerald/Program.cs index c869f64..2b3e63b 100644 --- a/JetHerald/Program.cs +++ b/JetHerald/Program.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using NLog.Web; @@ -18,6 +17,8 @@ try { log.Info("init main"); + DapperConverters.Register(); + var builder = WebApplication.CreateBuilder(args); builder.WebHost.ConfigureAppConfiguration((hostingContext, config) => @@ -45,6 +46,7 @@ try services.AddSingleton(); services.AddSingleton().AddHostedService(s => s.GetService()); services.AddSingleton(); + services.AddHostedService(); services.AddMvc(); diff --git a/JetHerald/Services/Db.cs b/JetHerald/Services/Db.cs index a50d568..28b425d 100644 --- a/JetHerald/Services/Db.cs +++ b/JetHerald/Services/Db.cs @@ -26,15 +26,15 @@ public class Db new { name }); } - public async Task GetTopicForSub(string token, NamespacedId chat) + public async Task GetTopicForSub(string token, NamespacedId sub) { using var c = GetConnection(); return await c.QuerySingleOrDefaultAsync( " SELECT t.*, ts.Sub " + " FROM topic t " + - " LEFT JOIN topic_sub ts ON t.TopicId = ts.TopicId AND ts.Chat = @chat " + + " LEFT JOIN topic_sub ts ON t.TopicId = ts.TopicId AND ts.Sub = @sub " + " WHERE ReadToken = @token", - new { token, chat }); + new { token, sub }); } public async Task CreateTopic(NamespacedId user, string name, string descr) @@ -95,7 +95,7 @@ public class Db " DELETE ts " + " FROM topic_sub ts" + " JOIN topic t USING (TopicId) " + - " WHERE t.Name = @topicName AND tc.Sub = @sub;", + " WHERE t.Name = @topicName AND ts.Sub = @sub;", new { topicName, sub }); } @@ -125,7 +125,7 @@ public class Db public async Task MarkHeartAttackReported(ulong id) { using var c = GetConnection(); - await c.ExecuteAsync("UPDATE heartevent SET Status = 'reported' WHERE HeartattackId = @id", new { id }); + await c.ExecuteAsync("UPDATE heartevent SET Status = 'reported' WHERE HeartEventId = @id", new { id }); } public Db(IOptionsMonitor cfg)