mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 10:27:18 +02:00
Operations pipeline start
This commit is contained in:
1 parent
6c10c6c654
commit
7ffbeb6b17
19 files changed
+432
-5
No files matched your search
@@ -0,0 +1,7 @@
|
||||
namespace WotBlitzStatisticsPro.DataAccess
|
||||
{
|
||||
public interface IWargamingAccountDataAccessor
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
|
||||
{
|
||||
/// <summary>
|
||||
/// Account information
|
||||
/// </summary>
|
||||
public class AccountInfo
|
||||
{
|
||||
///<summary>
|
||||
/// Player account identifier
|
||||
///</summary>
|
||||
[BsonId]
|
||||
public long AccountId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Player region
|
||||
/// </summary>
|
||||
public RealmType Realm { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Account creation date
|
||||
///</summary>
|
||||
public int CreatedAt { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Last battle time
|
||||
///</summary>
|
||||
public int LastBattleTime { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Player's nick
|
||||
///</summary>
|
||||
public string Nickname { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Player information update date
|
||||
///</summary>
|
||||
public int? UpdatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using MongoDB.Driver;
|
||||
using WotBlitzStatisticsPro.Common;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
|
||||
namespace WotBlitzStatisticsPro.DataAccess
|
||||
{
|
||||
public class WargamingAccountDataAccessor : IWargamingAccountDataAccessor
|
||||
{
|
||||
private const string AccountInfoCollectionName = "account-info";
|
||||
|
||||
|
||||
private readonly IMongoDatabase _database;
|
||||
|
||||
public WargamingAccountDataAccessor(IMongoSettings mongoSettings)
|
||||
{
|
||||
var client = new MongoClient(mongoSettings.ConnectionString);
|
||||
_database = client.GetDatabase(mongoSettings.DatabaseName);
|
||||
|
||||
CreateAccountIndexesIfNotExists();
|
||||
}
|
||||
|
||||
private void CreateAccountIndexesIfNotExists()
|
||||
{
|
||||
var accountInfoBuilder = Builders<AccountInfo>.IndexKeys;
|
||||
var accountInfoRealmIndexModel = new CreateIndexModel<AccountInfo>(accountInfoBuilder.Ascending(a => a.Realm));
|
||||
var accountInfoLastBattleTimeIndexModel = new CreateIndexModel<AccountInfo>(accountInfoBuilder.Descending(a => a.LastBattleTime));
|
||||
_database.GetCollection<AccountInfo>(AccountInfoCollectionName).Indexes
|
||||
.CreateMany(new[] {accountInfoRealmIndexModel, accountInfoLastBattleTimeIndexModel});
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// Multiple keys
|
||||
var indexDefinition = Builders<FooDocument>.IndexKeys.Combine(
|
||||
Builders<FooDocument>.IndexKeys.Ascending(f => f.Key1),
|
||||
Builders<FooDocument>.IndexKeys.Ascending(f => f.Key2));
|
||||
|
||||
await collection.Indexes.CreateOneAsync(indexDefinition);
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace WotBlitzStatisticsPro.DataAccess
|
||||
public static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IDictionariesDataAccessor, DictionariesDataAccessor>();
|
||||
services.AddTransient<IWargamingAccountDataAccessor, WargamingAccountDataAccessor>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user