- Moved update loop to a separate method.

- Added optimize flag to GlobalNadeko configuration.
- Added some packages which will be needed soon
This commit is contained in:
Kwoth
2022-03-21 12:00:44 +01:00
parent 798b66db9b
commit 1dc393d2b1
2 changed files with 148 additions and 137 deletions

View File

@@ -121,13 +121,16 @@ public class XpService : INService, IReadyExecutor
#endif #endif
} }
public Task OnReadyAsync() public async Task OnReadyAsync()
=> UpdateLoop();
private async Task UpdateLoop()
{ {
using var timer = new PeriodicTimer(5.Seconds()); using var timer = new PeriodicTimer(5.Seconds());
while (await timer.WaitForNextTickAsync()) while (await timer.WaitForNextTickAsync())
{
await UpdateLoop();
}
}
private async Task UpdateLoop()
{ {
try try
{ {
@@ -143,7 +146,7 @@ public class XpService : INService, IReadyExecutor
var group = toAddTo.GroupBy(x => (GuildId: x.Guild.Id, x.User)); var group = toAddTo.GroupBy(x => (GuildId: x.Guild.Id, x.User));
if (toAddTo.Count == 0) if (toAddTo.Count == 0)
continue; return;
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
{ {
@@ -269,7 +272,6 @@ public class XpService : INService, IReadyExecutor
Log.Error(ex, "Error In the XP update loop"); Log.Error(ex, "Error In the XP update loop");
} }
} }
}
private void InternalReloadXpTemplate() private void InternalReloadXpTemplate()

View File

@@ -35,12 +35,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Html2Markdown" Version="5.0.2.561" /> <PackageReference Include="Html2Markdown" Version="5.0.2.561" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
@@ -59,10 +53,22 @@
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0010" /> <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0010" />
<PackageReference Include="StackExchange.Redis" Version="2.2.88" /> <PackageReference Include="StackExchange.Redis" Version="2.2.88" />
<PackageReference Include="YamlDotNet" Version="11.2.1" /> <PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="linq2db.EntityFrameworkCore" Version="6.6.1" />
<PackageReference Include="Humanizer" Version="2.14.1" /> <PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" /> <PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
<!-- Db-related packages -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="linq2db.EntityFrameworkCore" Version="6.6.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
<!-- Remove this when static abstract interface members support is released --> <!-- Remove this when static abstract interface members support is released -->
<PackageReference Include="System.Runtime.Experimental" Version="6.0.0" /> <PackageReference Include="System.Runtime.Experimental" Version="6.0.0" />
@@ -105,6 +111,9 @@
<PropertyGroup Condition=" '$(Configuration)' == 'GlobalNadeko' "> <PropertyGroup Condition=" '$(Configuration)' == 'GlobalNadeko' ">
<DefineConstants>$(DefineConstants);GLOBAL_NADEKO</DefineConstants> <DefineConstants>$(DefineConstants);GLOBAL_NADEKO</DefineConstants>
<NoWarn>$(NoWarn);CS1573;CS1591</NoWarn> <NoWarn>$(NoWarn);CS1573;CS1591</NoWarn>
<Optimize>true</Optimize>
<DebugType>portable</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<!-- TODO: Remove this when the conflict issue in System.Runtime.Experimental is fixed --> <!-- TODO: Remove this when the conflict issue in System.Runtime.Experimental is fixed -->