Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ostorc committed Sep 19, 2022
2 parents 1653a59 + eaec8cf commit cb16b97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2022.4.1</Version>
<Version>2022.4.2</Version>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<PackageReference Update="xunit" Version="2.4.2" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Update="Shouldly" Version="4.1.0" />
<PackageReference Update="Html2Markdown" Version="4.0.0.427" />
<PackageReference Update="Html2Markdown" Version="5.0.2.561" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ public async Task EditLastRunConfigCommandAsync(InteractionContext ctx,
[SlashCommand("run-once", "Fetch news once")]
public async Task RunOnceCommandAsync(InteractionContext ctx)
{
await ctx.DeferAsync();
await _newsJobProvider.ExecuteAsync(default);
await ctx.CreateResponseAsync("News job - done");
await ctx.EditResponseAsync( new DiscordWebhookBuilder().WithContent("News job - done"));
}

private static DateTime? ParseDateTime(string datetime)
Expand Down
7 changes: 5 additions & 2 deletions src/HonzaBotner.Discord.Services/Jobs/NewsJobProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

namespace HonzaBotner.Discord.Services.Jobs;

[Cron("0 * * * * *")]
// Run every 30 minutes
[Cron("0 */30 * * * *")]
public class NewsJobProvider : IJob
{
private const int RunOffset = -3;

public string Name { get; } = "news-publisher";

private readonly ILogger<NewsJobProvider> _logger;
Expand Down Expand Up @@ -47,7 +50,7 @@ public async Task ExecuteAsync(CancellationToken cancellationToken)
scope.ServiceProvider.GetRequiredService(GetType(newsSource.Publisher.ToType())) as IPublisherService
?? throw new InvalidCastException("Type must be IPublisherService");

DateTime now = DateTime.Now;
DateTime now = DateTime.Now.AddMinutes(RunOffset);
IAsyncEnumerable<News> news = newsService.FetchDataAsync(newsSource.Source, newsSource.LastFetched);

await foreach (News item in news.WithCancellation(cancellationToken))
Expand Down

0 comments on commit cb16b97

Please sign in to comment.