Skip to content

Commit b346274

Browse files
committed
Add CronInterval option
1 parent 01ae251 commit b346274

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ If you want to specify this yourself, add `IgnoredResourceExtensions` to the con
161161

162162
## Restricting access to the Admin UI
163163

164-
By default, only users of `Administrators` role can access Admin UI. But you can configure you authorization policy when registrating the NotFound handler.
164+
By default, only users of `Administrators` role can access Admin UI. But you can configure your authorization policy when registering the NotFound handler.
165165

166166
```
167167
services.AddNotFoundHandler(o => { },
@@ -171,15 +171,15 @@ By default, only users of `Administrators` role can access Admin UI. But you can
171171
});
172172
```
173173

174-
You can setup any policy rules you want.
174+
You can set up any policy rules you want.
175175

176176
## Import
177177

178178
For details see [Import redirects for 404 handler](https://getadigital.com/blog/import-redirects-for-404-handler/) article.
179179

180180
# Custom 404 Page
181181

182-
To setup 404 page, you can use any method ASP.NET Core provides.
182+
To set up 404 page, you can use any method ASP.NET Core provides.
183183

184184
One of the simplest solutions is adding a controller and a view for it that would display an error page:
185185

@@ -275,7 +275,7 @@ It will monitor primary, secondary and SEO URLs:
275275
Optimizely Content Cloud supports only primary URLs and Optimizely Commerce supports all three types of URLs.
276276

277277
There are two scheduled jobs:
278-
- *[Geta NotFoundHandler] Index content URLs* - as mentioned before, this job indexes URLs of content. Usually, it is required to run this job only once. All new content is automatically indexed. But if for some reasons content publish events are not firing when creating new content (for example, during the import), then you should set this job to run frequently.
278+
- *[Geta NotFoundHandler] Index content URLs* - as mentioned before, this job indexes URLs of content. Usually, it is required to run this job only once. All new content is automatically indexed. But if for some reason content publish events are not firing when creating new content (for example, during the import), then you should set this job to run frequently.
279279
- *[Geta NotFoundHandler] Register content move redirects* - this job creates redirects based on registered moved content. Normally, this job is not required at all, but there might be situations when content move is registered but redirect creation is not completed. This could happen during deployments. In this case, you can manually run this job or schedule it to run time to time to fix such issues.
280280

281281
# Scheduled jobs
@@ -297,13 +297,14 @@ services.AddNotFoundHandler(o =>
297297
## Suggestions cleanup job
298298
Practice shows that the suggestions table grows quickly in production, so a suggestions cleanup job was added to control its growth.
299299

300-
This job is configured by default to run weekly, removing records older than 14 days.
300+
This job is configured by default to run daily at midnight, removing records older than 14 days.
301301
You can adjust the retention period as needed.
302302

303303
```
304304
services.AddNotFoundHandler(o =>
305305
{
306306
o.ScheduledJobs = true;
307+
o.SuggestionsCleanupOptions.CronInterval = "0 0 * * 0" // weekly on Sunday midnight
307308
o.SuggestionsCleanupOptions.DaysToKeep = 30;
308309
});
309310
```
@@ -327,7 +328,7 @@ For example, if we have a redirect: `/a` to `/b`, then:
327328
- without wildcard setting it will redirect `/a/1` to `/b/1`
328329

329330
# Sandbox App
330-
Sandbox application is testing poligon for pacakge new features and bug fixes.
331+
Sandbox application is testing polygon for package new features and bug fixes.
331332

332333
CMS username: admin@example.com
333334

src/Geta.NotFoundHandler/Core/ScheduledJobs/ApplicationBuilderExtensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
using Coravel;
55
using Geta.NotFoundHandler.Core.ScheduledJobs.Suggestions;
6+
using Geta.NotFoundHandler.Infrastructure.Configuration;
67
using Microsoft.AspNetCore.Builder;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Options;
710

811
namespace Geta.NotFoundHandler.Core.ScheduledJobs;
912

@@ -13,11 +16,13 @@ public static IApplicationBuilder UseScheduler(this IApplicationBuilder app)
1316
{
1417
var services = app.ApplicationServices;
1518

19+
var options = services.GetRequiredService<IOptions<NotFoundHandlerOptions>>().Value;
20+
1621
services.UseScheduler(scheduler =>
1722
{
1823
scheduler
1924
.Schedule<SuggestionsCleanupJob>()
20-
.Weekly()
25+
.Cron(options.SuggestionsCleanupOptions.CronInterval)
2126
.PreventOverlapping(nameof(SuggestionsCleanupJob));
2227
});
2328

src/Geta.NotFoundHandler/Core/Suggestions/SuggestionsCleanupOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public class SuggestionsCleanupOptions
77
{
88
public int DaysToKeep { get; set; } = 14;
99
public int Timeout { get; set; } = 30 * 60;
10+
public string CronInterval { get; set; } = "0 0 * * *";
1011
}

0 commit comments

Comments
 (0)