Minor logging changes

This commit is contained in:
Tom
2024-10-20 19:28:16 +00:00
parent 0fa0ddcc45
commit 5d69c647cf
3 changed files with 15 additions and 9 deletions

View File

@@ -58,34 +58,40 @@ namespace HermesSocketServer.Store
public override async Task<bool> Save()
{
int count = 0;
string sql = string.Empty;
if (_added.Any())
{
string sql = string.Empty;
lock (_lock)
{
count = _added.Count;
sql = _generator.GenerateInsertSql("User", _added.Select(a => _store[a]), ["id", "name", "email", "role", "ttsDefaultVoice"]);
_added.Clear();
}
_logger.Debug($"User - Adding {count} rows to database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_modified.Any())
{
string sql = string.Empty;
lock (_lock)
{
count = _modified.Count;
sql = _generator.GenerateUpdateSql("User", _modified.Select(m => _store[m]), ["id"], ["name", "email", "role", "ttsDefaultVoice"]);
_modified.Clear();
}
_logger.Debug($"User - Modifying {count} rows in database: {sql}");
await _database.ExecuteScalar(sql);
}
if (_deleted.Any())
{
string sql = string.Empty;
lock (_lock)
{
count = _deleted.Count;
sql = _generator.GenerateDeleteSql("User", _deleted, ["id"]);
_deleted.Clear();
}
_logger.Debug($"User - Deleting {count} rows from database: {sql}");
await _database.ExecuteScalar(sql);
}
return true;