James Tombleson
adb4799206
* Added jobs Controller to trigger collection. * Added backgroundjobs to move them out of program.cs * new column to track youtube ID values and adding a sourceid column on the icon for linking * Added icon table repo * added interface for IconsRepo * hey the missing config models * adding section const keys to pull blocks of configs * Added youtubewatcher to the code but not ready to enable it in the background. More testing needed. * Test... improvements?
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using Hangfire;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
using Newsbot.Collector.Database.Repositories;
|
|
using Newsbot.Collector.Domain.Interfaces;
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
namespace Newsbot.Collector.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/jobs")]
|
|
public class JobsController
|
|
{
|
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
|
private readonly ConfigSectionRssModel _rssConfig;
|
|
private readonly ILogger<SourcesController> _logger;
|
|
private readonly ISourcesRepository _sources;
|
|
|
|
public JobsController(ILogger<SourcesController> logger, IOptions<ConfigSectionConnectionStrings> connectionStrings,
|
|
IOptions<ConfigSectionRssModel> rss)
|
|
{
|
|
_logger = logger;
|
|
_connectionStrings = connectionStrings.Value;
|
|
_rssConfig = rss.Value;
|
|
_sources = new SourcesTable(connectionStrings.Value.Database ?? "");
|
|
}
|
|
|
|
[HttpPost("check/rss")]
|
|
public void CheckReddit()
|
|
{
|
|
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
|
{
|
|
ConnectionStrings = _connectionStrings,
|
|
Config = _rssConfig
|
|
}));
|
|
}
|
|
|
|
[HttpPost("check/youtube")]
|
|
public void CheckYoutube()
|
|
{
|
|
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
|
{
|
|
ConnectionStrings = _connectionStrings
|
|
}));
|
|
}
|
|
} |