Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Crypto.Compare.Adapter.AdaptersObservable;
using Crypto.Compare.DataAccess;
using EFCore.BulkExtensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
Expand All @@ -15,6 +16,9 @@ public class SymbolProviderUpdateDatabaseQueueService : BackgroundService
/// </summary>
private const int WaitTimeout = 3000;

private static List<string> propertyExclude = new() { "Symbol" };


private readonly ISymbolProviderUpdateDatabaseQueue _symbolProviderUpdateDatabaseQueue;
private readonly ILogger<SymbolProviderUpdateDatabaseQueueService> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
Expand All @@ -29,7 +33,7 @@ public SymbolProviderUpdateDatabaseQueueService(ISymbolProviderUpdateDatabaseQue
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("Updated database symbols provider Background Service is starting.");

using var scope = _serviceScopeFactory.CreateScope();
await using var dbContext = scope.ServiceProvider.GetService<CryptoCompareContext>();

Expand All @@ -44,14 +48,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
continue;
}


await dbContext.BulkUpdateAsync(models, option =>
{
option.IgnoreOnUpdateExpression = c => new { c.Symbol };
}, stoppingToken );
option.PropertiesToExclude = propertyExclude;
}, cancellationToken: stoppingToken);

_logger.LogDebug("Update prices database for: {Count} symbols", models.Count);

}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EFCore.BulkExtensions" Version="10.0.1" />
<PackageReference Include="EFCore.BulkExtensions.PostgreSql" Version="10.0.1" />
<PackageReference Include="FluentResults" Version="4.0.0" />
<PackageReference Include="MediatR" Version="12.5.0" />
<PackageReference Include="MediatR" Version="14.1.0" />
<PackageReference Include="MediatR.Contracts" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="10.105.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Crypto.Compare.Services.Results.SymbolProviders;

namespace Crypto.Compare.Services.Results.SymbolProviders;

public class SymbolProviderResult
public class SymbolProviderResult : IHandlerResult
{

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Crypto.Compare.Data;
namespace Crypto.Compare.Services.Results.Symbols;
namespace Crypto.Compare.Services.Results.Symbols;

public class GetSymbolsResult : IHandlerResult
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Crypto.Compare.Services.Results.Symbols;

public class SymbolResult
public class SymbolResult : IHandlerResult
{
/// <summary>
/// Uniq id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
<PackageReference Include="FluentAssertions" Version="7.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JK.BingX.Net" Version="3.0.1" />
<PackageReference Include="JK.BingX.Net" Version="3.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BitMart.Net" Version="3.0.1" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="10.105.2" />
<PackageReference Include="BitMart.Net" Version="3.8.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JK.Bitget.Net" Version="3.0.0" />
<PackageReference Include="JK.Bitget.Net" Version="3.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bybit.Net" Version="6.0.0" />
<PackageReference Include="Bybit.Net" Version="6.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GateIo.Net" Version="3.0.0" />
<PackageReference Include="GateIo.Net" Version="3.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="JK.Mexc.Net" Version="4.0.2" />
<PackageReference Include="JK.Mexc.Net" Version="4.8.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ProjectReference Include="..\..\core\Crypto.Compare.Data\Crypto.Compare.Data.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="XT.Net" Version="3.0.1" />
<PackageReference Include="XT.Net" Version="3.8.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<FileVersion>1.0.100.$([System.DateTime]::UtcNow.ToString("ddHH"))</FileVersion>
<FileVersion>1.0.101.$([System.DateTime]::UtcNow.ToString("ddHH"))</FileVersion>
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="14.0.0" />
<PackageReference Include="BitMart.Net" Version="3.0.1" />
<PackageReference Include="BitMart.Net" Version="3.8.0" />
<PackageReference Include="FluentResults" Version="4.0.0" />
<PackageReference Include="FluentValidation" Version="12.0.0" />
<PackageReference Include="log4net" Version="3.2.0" />
<PackageReference Include="FluentValidation" Version="12.1.1" />
<PackageReference Include="log4net" Version="3.3.0" />
<PackageReference Include="Mapster" Version="10.0.3" />
<PackageReference Include="Mapster.Core" Version="10.0.1" />
<PackageReference Include="Mapster.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.3.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.3.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters.Abstractions" Version="8.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.5" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.1.5" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="10.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AutoMapper;
using Crypto.Compare.Adapter;
using Crypto.Compare.Adapter;
using Crypto.Compare.Adapter.AdaptersObservable;
using Crypto.Compare.Adapter.Impl;
using Crypto.Compare.BingX;
Expand Down Expand Up @@ -34,6 +33,8 @@
using Crypto.Compare.Xtcom;
using CryptoExchange.Net.Authentication;
using FluentResults;
using Mapster;
using MapsterMapper;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
Expand All @@ -48,9 +49,22 @@ internal static IServiceCollection AddServices(this IServiceCollection services,
.AddConfigurations(configuration)
.AddMediator()
.AddSingletons()
.AddMapper()
.AddExternalServices()
.AddAdapters(configuration)
;
.AddAdapters(configuration);


}

private static IServiceCollection AddMapper(this IServiceCollection services)
{
// Mapster
var config = TypeAdapterConfig.GlobalSettings;
config.Apply(new MapsterProfile());
services.AddSingleton(config);
services.AddSingleton<IResponseMapper, ResponseMapper>();
services.AddSingleton<IMapper, ServiceMapper>();
return services;
}

private static IServiceCollection AddConfigurations(this IServiceCollection services, IConfiguration configuration)
Expand All @@ -72,7 +86,7 @@ private static IServiceCollection AddAdapters(this IServiceCollection services,

services.AddSingleton<IAdaptersObservable, AdaptersObservable>();
services.AddSingleton<ISymbolProviderChangeQueue, SymbolProviderChangeQueue>();

services.AddSingleton<ISymbolProviderUpdateDatabaseQueue, SymbolProviderUpdateDatabaseQueue>();
services.AddSingleton<ISymbolProviderAddDatabaseQueue, SymbolProviderAddDatabaseQueue>();
services.AddSingleton<ISymbolProviderSenderQueue, SymbolProviderSenderQueue>();
Expand All @@ -82,8 +96,8 @@ private static IServiceCollection AddAdapters(this IServiceCollection services,

services.AddSingleton<IWebSocketMessagesManager, WebSocketMessagesManager>();
services.AddSingleton<IWebSocketDisconnectManager, WebSocketDisconnectManager>();
services.AddSingleton<ISymbolsSubscribes, SymbolsSubscribes>();

services.AddSingleton<ISymbolsSubscribes, SymbolsSubscribes>();

services.AddHostedService<ListenerStarterHostedService>();

Expand Down Expand Up @@ -229,8 +243,6 @@ private static (string? ApiKey, string? ApiSecret, string? passwordKey) LoadCred
private static IServiceCollection AddSingletons(this IServiceCollection services)
{
return services
.AddSingleton<IResponseMapper, ResponseMapper>()
.AddSingleton(_ => new MapperConfiguration(cfg => { cfg.AddProfile<AutoMapperProfile>(); }).CreateMapper())
.AddSingleton<ISymbolProvidersCache, SymbolProvidersCache>()
.AddSingleton<ISymbolsCache, SymbolsCache>()
.AddSingleton<IWebSocketHandler, WebSocketHandler>()
Expand All @@ -253,7 +265,7 @@ private static IServiceCollection AddMediator(this IServiceCollection services)
.AddScoped<IRequestHandler<GetProviderQuery, Result<Provider>>, GetProviderQueryHandler>()
.AddScoped<IRequestHandler<GetProvidersQuery, Result<GetProvidersResult>>, GetProvidersQueryHandler>()
.AddScoped<IRequestHandler<GetSymbolProvidersQuery, Result<GetSymbolProviderResult>>, GetSymbolProvidersQueryHandler>()

;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Crypto.Compare.Data;
using Crypto.Compare.PublicApi.Dtos;
using Crypto.Compare.PublicApi.Responses.v1.Providers;
using Crypto.Compare.PublicApi.Responses.v1.SymbolProvider;
using Crypto.Compare.PublicApi.Responses.v1.Symbols;
using Crypto.Compare.Services.Results.Providers;
using Crypto.Compare.Services.Results.SymbolProviders;
using Crypto.Compare.Services.Results.Symbols;
using Mapster;

namespace Crypto.Compare.PublicApi.Mapping;

public class MapsterProfile : IRegister
{
public void Register(TypeAdapterConfig config)
{
// Простые маппинги (аналогичны CreateMap)
config.NewConfig<SymbolProvider, SymbolProviderDto>();
config.NewConfig<SymbolResult, SymbolDto>();
config.NewConfig<SymbolProvider, GetSymbolResponse>();
config.NewConfig<GetSymbolsResult, GetSymbolsResponse>();
config.NewConfig<GetSymbolProviderResult, GetSymbolsProviderResponse>();
config.NewConfig<SymbolProviderResult, SymbolProviderDto>();

config.NewConfig<Provider, ProviderDto>();
config.NewConfig<Provider, GetProviderResponse>();
config.NewConfig<GetProvidersResult, GetProvidersResponse>();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using AutoMapper;
using Crypto.Compare.PublicApi.Extensions;
using Crypto.Compare.PublicApi.Extensions;
using Crypto.Compare.PublicApi.Responses;
using FluentResults;
using MapsterMapper;
using Microsoft.AspNetCore.Mvc;

namespace Crypto.Compare.PublicApi.Mapping;
Expand Down
1 change: 0 additions & 1 deletion sources/presentation/Crypto.Compare.PublicApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Reflection;
using System.Text.Json.Serialization;
using Microsoft.OpenApi;
using Microsoft.OpenApi.Models;
using ApiRequestValidationFilter = Crypto.Compare.PublicApi.Filters.ApiRequestValidationFilter;

var builder = WebApplication.CreateBuilder(args);
Expand Down
Loading
Loading