File tree Expand file tree Collapse file tree 5 files changed +22
-2
lines changed
tests/LinkDotNet.Blog.UnitTests/Web/Features/Admin/Settings Expand file tree Collapse file tree 5 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 11@page " /settings"
22@using LinkDotNet .Blog .Web .Features .Services
3+ @using LinkDotNet .NCronJob
34@inject IOptions <ApplicationConfiguration > ApplicationConfiguration
45@inject ICacheInvalidator CacheInvalidator
56@inject IToastService ToastService
7+ @inject IInstantJobRegistry InstantJobRegistry
68@attribute [Authorize]
79
810<div class =" container-fluid ms-3" >
2527 <td >@ApplicationConfiguration.Value.FirstPageCacheDurationInMinutes Minutes</td >
2628 <td ><button class =" btn btn-warning" id =" invalidate-cache" @onclick =" InvalidateCache" >Invalidate Cache</button ></td >
2729 </tr >
30+ <tr >
31+ <td >Run Visit Counter Data Collection</td >
32+ <td >The visit counter data collection is a background job that collects the visit data of the blog posts.<br />
33+ The job runs every hour (on the hour). The job can be run on demand.</td >
34+ <td ></td >
35+ <td ><button class =" btn btn-warning" id =" run-visit-transformer" @onclick =" RunVisitTransformer" >Run transformer</button ></td >
36+ </tr >
2837 </tbody >
2938 </table >
3039</div >
3544 CacheInvalidator .Cancel ();
3645 ToastService .ShowInfo (" Cache was invalidated." );
3746 }
47+
48+ private void RunVisitTransformer ()
49+ {
50+ InstantJobRegistry .AddInstantJob <TransformBlogPostRecordsService >();
51+ ToastService .ShowInfo (" Transformer was started." );
52+ }
3853}
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ private static void RegisterServices(WebApplicationBuilder builder)
3838 builder . Services . RegisterServices ( ) ;
3939 builder . Services . AddStorageProvider ( builder . Configuration ) ;
4040 builder . Services . AddResponseCompression ( ) ;
41- builder . Services . AddBackgroundServices ( ) ;
4241
4342 builder . Services . AddHealthChecks ( )
4443 . AddCheck < DatabaseHealthCheck > ( "Database" ) ;
Original file line number Diff line number Diff line change 1+ using System ;
12using LinkDotNet . Blog . Web . Features ;
23using LinkDotNet . NCronJob ;
34using Microsoft . Extensions . DependencyInjection ;
@@ -15,7 +16,7 @@ public static void AddBackgroundServices(this IServiceCollection services)
1516 options . ServicesStopConcurrently = true ;
1617 } ) ;
1718
18- services . AddNCronJob ( ) ;
19+ services . AddNCronJob ( p => p . TimerInterval = TimeSpan . FromSeconds ( 30 ) ) ;
1920 services . AddCronJob < BlogPostPublisher > ( p => p . CronExpression = "* * * * *" ) ;
2021 services . AddCronJob < TransformBlogPostRecordsService > ( p => p . CronExpression = "0 * * * *" ) ;
2122 }
Original file line number Diff line number Diff line change 11using LinkDotNet . Blog . Web . Features . Admin . BlogPostEditor . Services ;
22using LinkDotNet . Blog . Web . Features . Admin . Sitemap . Services ;
33using LinkDotNet . Blog . Web . Features . Services ;
4+ using LinkDotNet . Blog . Web . RegistrationExtensions ;
45using Microsoft . Extensions . DependencyInjection ;
56
67namespace LinkDotNet . Blog . Web ;
@@ -19,5 +20,7 @@ public static void RegisterServices(this IServiceCollection services)
1920 services . AddSingleton < CacheService > ( ) ;
2021 services . AddSingleton < ICacheTokenProvider > ( s => s . GetRequiredService < CacheService > ( ) ) ;
2122 services . AddSingleton < ICacheInvalidator > ( s => s . GetRequiredService < CacheService > ( ) ) ;
23+
24+ services . AddBackgroundServices ( ) ;
2225 }
2326}
Original file line number Diff line number Diff line change 22using LinkDotNet . Blog . Web ;
33using LinkDotNet . Blog . Web . Features . Admin . Settings ;
44using LinkDotNet . Blog . Web . Features . Services ;
5+ using LinkDotNet . NCronJob ;
56using Microsoft . Extensions . DependencyInjection ;
67using Microsoft . Extensions . Options ;
78
@@ -16,6 +17,7 @@ public void GivenSettingsPage_WhenClicking_InvalidateCacheButton_TokenIsCancelle
1617 Services . AddScoped ( _ => cacheInvalidator ) ;
1718 Services . AddScoped ( _ => Options . Create < ApplicationConfiguration > ( new ( ) ) ) ;
1819 Services . AddScoped ( _ => Substitute . For < IToastService > ( ) ) ;
20+ Services . AddScoped ( _ => Substitute . For < IInstantJobRegistry > ( ) ) ;
1921 var cut = Render < SettingsPage > ( ) ;
2022 var invalidateCacheButton = cut . Find ( "#invalidate-cache" ) ;
2123
You can’t perform that action at this time.
0 commit comments