88using Microsoft . EntityFrameworkCore ;
99
1010namespace Lumen . Modules . SteamPartner . Module {
11- public class SteamPartnerModule ( IEnumerable < ConfigEntry > configEntries , ILogger < LumenModuleBase > logger , IServiceProvider provider ) : LumenModuleBase ( configEntries , logger , provider ) {
12- public override async Task InitAsync ( LumenModuleRunsOnFlag currentEnv ) {
13- await RunAsync ( currentEnv , DateTime . UtcNow ) ;
14- }
11+ public class SteamPartnerModule ( IEnumerable < ConfigEntry > configEntries , ILogger < LumenModuleBase > logger , IServiceProvider provider ) : LumenModuleBase ( configEntries , logger , provider ) {
12+ public override async Task InitAsync ( LumenModuleRunsOnFlag currentEnv ) {
13+ await RunAsync ( currentEnv , DateTime . UtcNow ) ;
14+ }
1515
1616 public override async Task RunAsync ( LumenModuleRunsOnFlag currentEnv , DateTime date ) {
1717 try {
@@ -23,27 +23,27 @@ public override async Task RunAsync(LumenModuleRunsOnFlag currentEnv, DateTime d
2323 }
2424 }
2525
26- public override bool ShouldRunNow ( LumenModuleRunsOnFlag currentEnv , DateTime date ) {
27- return currentEnv == LumenModuleRunsOnFlag . API && date . Second == 0 && date . Minute == 0 && date . Hour == 6 ;
28- }
29-
30- public override Task ShutdownAsync ( ) {
31- // Nothing to do
32- return Task . CompletedTask ;
33- }
34-
35- public static new void SetupServices ( LumenModuleRunsOnFlag currentEnv , IServiceCollection serviceCollection , string ? postgresConnectionString ) {
36- if ( currentEnv == LumenModuleRunsOnFlag . API ) {
37- serviceCollection . AddDbContext < SteamPartnerContext > ( o => o . UseNpgsql ( postgresConnectionString , x => x . MigrationsHistoryTable ( "__EFMigrationsHistory" , SteamPartnerContext . SCHEMA_NAME ) ) ) ;
38- serviceCollection . AddTransient < ISteamPartnerStats , SteamPartnerStats > ( ) ;
39- serviceCollection . AddTransient < ISteamCommunity , SteamCommunity > ( ) ;
40- serviceCollection . AddTransient < ISteamPartner , Dysnomia . Common . SteamWebAPI . SteamPartner > ( ) ;
41- serviceCollection . AddHttpClient ( ) ;
42- }
43- }
44-
45- public override Type GetDatabaseContextType ( ) {
46- return typeof ( SteamPartnerContext ) ;
47- }
48- }
26+ public override bool ShouldRunNow ( LumenModuleRunsOnFlag currentEnv , DateTime date ) {
27+ return currentEnv == LumenModuleRunsOnFlag . API && date . Second == 0 && date . Minute == 0 && date . Hour == 6 ;
28+ }
29+
30+ public override Task ShutdownAsync ( ) {
31+ // Nothing to do
32+ return Task . CompletedTask ;
33+ }
34+
35+ public static new void SetupServices ( LumenModuleRunsOnFlag currentEnv , IServiceCollection serviceCollection , string ? postgresConnectionString ) {
36+ if ( currentEnv == LumenModuleRunsOnFlag . API ) {
37+ serviceCollection . AddDbContext < SteamPartnerContext > ( o => o . UseNpgsql ( postgresConnectionString , x => x . MigrationsHistoryTable ( "__EFMigrationsHistory" , SteamPartnerContext . SCHEMA_NAME ) ) ) ;
38+ serviceCollection . AddTransient < ISteamPartnerStats , SteamPartnerStats > ( ) ;
39+ serviceCollection . AddTransient < ISteamCommunity , SteamCommunity > ( ) ;
40+ serviceCollection . AddTransient < ISteamPartner , Dysnomia . Common . SteamWebAPI . SteamPartner > ( ) ;
41+ serviceCollection . AddHttpClient ( ) ;
42+ }
43+ }
44+
45+ public override Type GetDatabaseContextType ( ) {
46+ return typeof ( SteamPartnerContext ) ;
47+ }
48+ }
4949}
0 commit comments