Start counting messages in postgres
This commit is contained in:
parent
449e1e0adc
commit
6a163366ea
1 changed files with 18 additions and 17 deletions
|
@ -105,23 +105,24 @@ namespace Geekbot.net
|
||||||
|
|
||||||
var channel = (SocketGuildChannel) message.Channel;
|
var channel = (SocketGuildChannel) message.Channel;
|
||||||
|
|
||||||
// var rowId = await _messageCounterDatabaseContext.Database.ExecuteSqlCommandAsync(
|
// just testing, redis will remain the source of truth for now
|
||||||
// "UPDATE \"Messages\" SET \"MessageCount\" = \"MessageCount\" + 1 WHERE \"GuildId\" = {0} AND \"UserId\" = {1}",
|
var rowId = await _messageCounterDatabaseContext.Database.ExecuteSqlCommandAsync(
|
||||||
// channel.Guild.Id.AsLong(),
|
"UPDATE \"Messages\" SET \"MessageCount\" = \"MessageCount\" + 1 WHERE \"GuildId\" = {0} AND \"UserId\" = {1}",
|
||||||
// message.Author.Id.AsLong()
|
channel.Guild.Id.AsLong(),
|
||||||
// );
|
message.Author.Id.AsLong()
|
||||||
//
|
);
|
||||||
// if (rowId == 0)
|
|
||||||
// {
|
if (rowId == 0)
|
||||||
// _messageCounterDatabaseContext.Messages.Add(new MessagesModel
|
{
|
||||||
// {
|
_messageCounterDatabaseContext.Messages.Add(new MessagesModel
|
||||||
// UserId = message.Author.Id.AsLong(),
|
{
|
||||||
// GuildId = channel.Guild.Id.AsLong(),
|
UserId = message.Author.Id.AsLong(),
|
||||||
// MessageCount = 1
|
GuildId = channel.Guild.Id.AsLong(),
|
||||||
// });
|
MessageCount = 1
|
||||||
// _messageCounterDatabaseContext.SaveChanges();
|
});
|
||||||
// }
|
_messageCounterDatabaseContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
await _redis.Db.HashIncrementAsync($"{channel.Guild.Id}:Messages", message.Author.Id.ToString());
|
await _redis.Db.HashIncrementAsync($"{channel.Guild.Id}:Messages", message.Author.Id.ToString());
|
||||||
await _redis.Db.HashIncrementAsync($"{channel.Guild.Id}:Messages", 0.ToString());
|
await _redis.Db.HashIncrementAsync($"{channel.Guild.Id}:Messages", 0.ToString());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue