Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andreygolubkow committed Feb 3, 2024
1 parent 217207e commit d47f5c4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 229 deletions.
160 changes: 0 additions & 160 deletions TaktTusur.Media.Background.Core/Services/NewsFetchingAsyncJob.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace TaktTusur.Media.BackgroundCrawling.Core.Services;
/// Entity for replication,
/// should be <see cref="IIdentifiable"/> and <see cref="IReplicated"/>
/// </typeparam>
public abstract class ReplicatingJobBase<T> : IAsyncJob where T: IIdentifiable, IReplicated
public abstract class ReplicationJobBase<T> : IAsyncJob where T: IIdentifiable, IReplicated
{
protected const string StartWorkingMsg = $"{nameof(ReplicatingJobBase<T>)} job is started";
protected const string FinishWorkingMsg = $"{nameof(ReplicatingJobBase<T>)} job is finished";
protected const string InterruptedMsg = $"{nameof(ReplicatingJobBase<T>)} job was interrupted";
protected const string DisabledMsg = $"{nameof(ReplicatingJobBase<T>)} job is disabled";
protected const string StartWorkingMsg = $"{nameof(ReplicationJobBase<T>)} job is started";
protected const string FinishWorkingMsg = $"{nameof(ReplicationJobBase<T>)} job is finished";
protected const string InterruptedMsg = $"{nameof(ReplicationJobBase<T>)} job was interrupted";
protected const string DisabledMsg = $"{nameof(ReplicationJobBase<T>)} job is disabled";

private readonly IRemoteSource<T> _remoteSource;
private readonly IRepository<T> _repository;
Expand All @@ -31,7 +31,7 @@ public abstract class ReplicatingJobBase<T> : IAsyncJob where T: IIdentifiable,
/// <param name="repository">Repository for <see cref="T"/> </param>
/// <param name="logger">Logger</param>
/// <param name="jobSettings">Settings for the job, don't take it from DI</param>
protected ReplicatingJobBase(
protected ReplicationJobBase(
IRemoteSource<T> remoteSource,
IRepository<T> repository,
ILogger logger,
Expand Down Expand Up @@ -104,7 +104,7 @@ public virtual async Task<JobResult> ExecuteAsync(CancellationToken token)
/// </summary>
/// <remarks>
/// You don't have to call <see cref="IRepository{TEntity}.SaveAsync()"/> here.
/// It will be called by <see cref="ReplicatingJobBase{T}"/>
/// It will be called by <see cref="ReplicationJobBase{T}"/>
/// </remarks>
/// <param name="remoteItem">Item from remote resource.</param>
/// <returns>true - if item was updated, false - if item not found.</returns>
Expand All @@ -125,7 +125,7 @@ public virtual async Task<JobResult> ExecuteAsync(CancellationToken token)
/// <param name="item">New item <see cref="IIdentifiable"/>, <see cref="IReplicated"/></param>
/// <remarks>
/// You don't have to call <see cref="IRepository{TEntity}.SaveAsync()"/> here.
/// It will be called by <see cref="ReplicatingJobBase{T}"/>
/// It will be called by <see cref="ReplicationJobBase{T}"/>
/// </remarks>
protected abstract void AddNewItem(T item);

Expand Down Expand Up @@ -215,23 +215,4 @@ private async Task ProcessItems(List<T> items)
await _repository.SaveAsync();
}
}

// private bool TryUpdateExistingItem(T remoteItem)
// {
// // OriginalReference was verified previously
// var localArticle = _repository.GetByOriginalReference(remoteArticle.OriginalReference!);
// if (localArticle == null) return false;
// localArticle.OriginalLastUpdated = remoteArticle.OriginalLastUpdated;
// localArticle.Text =
// _textTransformer.MakeShorter(remoteArticle.Text, _settings.MaxSymbolsCount, _settings.MaxParagraphCount);
// localArticle.LastUpdated = _environment.GetCurrentDateTime();
// return true;
// }

// private void AddNewItem(T item)
// {
// item.Text = _textTransformer.MakeShorter(item.Text);
// item.LastUpdated = _environment.GetCurrentDateTime();
// _articlesRepository.Add(item);
// }
}
2 changes: 1 addition & 1 deletion TaktTusur.Media.Background.Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
services.AddQuartz((options) =>
{
options.AddJob<NewsFetchingQuartzJob>(JobKey.Create(nameof(NewsFetchingQuartzJob)));
options.AddJob<ArticlesFetchingQuartzJob>(JobKey.Create(nameof(ArticlesFetchingQuartzJob)));
});
services.AddQuartzHostedService((options) =>
{
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions TaktTusur.Media.Core/Interfaces/IReplicated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ namespace TaktTusur.Media.Core.Interfaces;

public interface IReplicated
{
public string OriginalSource { get; }
public string? OriginalSource { get; }

public string OriginalId { get; }
public string? OriginalId { get; }

public DateTimeOffset OriginalUpdatedAt { get; }
public DateTimeOffset? OriginalUpdatedAt { get; }
}
13 changes: 6 additions & 7 deletions TaktTusur.Media.Core/News/Article.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using TaktTusur.Media.BackgroundCrawling.Core.Entities;
using TaktTusur.Media.Core.Interfaces;

namespace TaktTusur.Media.Core.News;

public class Article : IIdentifiable
public class Article : IIdentifiable, IReplicated
{
public long Id { get; }

public string? SourceIdentifier { get; set; }

public string? OriginalReference { get; set; }

public string Text { get; set; }

public DateTimeOffset? OriginalLastUpdated { get; set; }

public DateTimeOffset LastUpdated { get; set; }

public string? OriginalSource { get; }
public string? OriginalId { get; }
public DateTimeOffset? OriginalUpdatedAt { get; }
}

0 comments on commit d47f5c4

Please sign in to comment.