Compare commits
8 Commits
731b2cf9b7
...
0797fb8502
Author | SHA1 | Date | |
---|---|---|---|
0797fb8502 | |||
2c886d22ad | |||
0b68261181 | |||
f2995ff156 | |||
a6ea89be62 | |||
7d176cb643 | |||
3e3da9027f | |||
4f46247d0c |
11
Dockerfile
11
Dockerfile
@ -14,21 +14,20 @@ FROM build AS publish
|
||||
RUN dotnet publish -c Release -o /app/publish
|
||||
|
||||
RUN dotnet publish -o build
|
||||
#--self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
|
||||
RUN ls build
|
||||
|
||||
FROM build as ef
|
||||
RUN dotnet tool install dotnet-ef --tool-path /usr/bin
|
||||
RUN dotnet ef migrations bundle --project "Newsbot.Collector.Database"
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0.3 as app
|
||||
|
||||
ENV ASPNETCORE_URLS=http://*:5000
|
||||
ENV DOTNET_URLS=http://*:5000
|
||||
|
||||
#RUN apt-get install chromium -y
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
#RUN mkdir /migrations
|
||||
COPY --from=publish /app/build /app
|
||||
#COPY --from=build ./app/Newsbot.Collector.Database/Migrations /app/migrations
|
||||
#COPY --from=goose /go/bin/goose /app
|
||||
COPY --from=ef /app/efbundle /app
|
||||
|
||||
CMD [ "dotnet", "Newsbot.Collector.Api.dll" ]
|
@ -43,7 +43,7 @@ public class ArticlesController : ControllerBase
|
||||
public ArticleDetailsDto GetDetailsById(Guid id)
|
||||
{
|
||||
var item = _articles.GetById(id);
|
||||
var sourceItem = _sources.GetByID(item.SourceID);
|
||||
var sourceItem = _sources.GetById(item.SourceId);
|
||||
return ArticleDetailsDto.Convert(item, sourceItem);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Dto;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
@ -40,12 +41,12 @@ public class DiscordWebHookController : ControllerBase
|
||||
{
|
||||
var exists = _webhooks.GetByUrl(url);
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
if (exists.ID != Guid.Empty)
|
||||
if (exists.Id != Guid.Empty)
|
||||
{
|
||||
return DiscordWebHookDto.Convert(exists);
|
||||
}
|
||||
|
||||
var res = _webhooks.New(new DiscordWebHookModel
|
||||
var res = _webhooks.New(new DiscordWebhookEntity
|
||||
{
|
||||
Url = url,
|
||||
Server = server,
|
||||
@ -72,7 +73,7 @@ public class DiscordWebHookController : ControllerBase
|
||||
[HttpGet("{id}")]
|
||||
public DiscordWebHookDto GetById(Guid id)
|
||||
{
|
||||
var res = _webhooks.GetByID(id);
|
||||
var res = _webhooks.GetById(id);
|
||||
return DiscordWebHookDto.Convert(res);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ using Microsoft.Extensions.Options;
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Consts;
|
||||
using Newsbot.Collector.Domain.Dto;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Services.HtmlParser;
|
||||
@ -39,10 +40,10 @@ public class SourcesController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("by/type")]
|
||||
public IEnumerable<SourceDto> GetByType(string type)
|
||||
public IEnumerable<SourceDto> GetByType(string type, int page)
|
||||
{
|
||||
var res = new List<SourceDto>();
|
||||
var temp = _sources.ListByType(type);
|
||||
var temp = _sources.ListByType(type, page);
|
||||
foreach (var item in temp) res.Add(SourceDto.Convert(item));
|
||||
return res;
|
||||
}
|
||||
@ -51,7 +52,7 @@ public class SourcesController : ControllerBase
|
||||
public SourceDto NewReddit(string name)
|
||||
{
|
||||
var res = _sources.GetByNameAndType(name, SourceTypes.Reddit);
|
||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
||||
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||
|
||||
var uri = new Uri($"https://reddit.com/r/{name}");
|
||||
|
||||
@ -61,7 +62,7 @@ public class SourcesController : ControllerBase
|
||||
});
|
||||
pageReader.Parse();
|
||||
|
||||
var item = _sources.New(new SourceModel
|
||||
var item = _sources.New(new SourceEntity
|
||||
{
|
||||
Site = SourceTypes.Reddit,
|
||||
Name = name,
|
||||
@ -74,11 +75,11 @@ public class SourcesController : ControllerBase
|
||||
|
||||
// Not all subreddits have an Icon, so we only want to add a record when it has one.
|
||||
if (pageReader.Data.Header.Image != "")
|
||||
_icons.New(new IconModel
|
||||
_icons.New(new IconEntity()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FileName = pageReader.Data.Header.Image,
|
||||
SourceId = item.ID
|
||||
SourceId = item.Id
|
||||
});
|
||||
return SourceDto.Convert(item);
|
||||
}
|
||||
@ -87,9 +88,9 @@ public class SourcesController : ControllerBase
|
||||
public SourceDto NewRss(string name, string url)
|
||||
{
|
||||
var res = _sources.GetByNameAndType(name, SourceTypes.Rss);
|
||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
||||
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||
|
||||
var m = new SourceModel
|
||||
var m = new SourceEntity
|
||||
{
|
||||
Site = SourceTypes.Rss,
|
||||
Name = name,
|
||||
@ -107,7 +108,7 @@ public class SourcesController : ControllerBase
|
||||
public SourceDto NewYoutube(string url)
|
||||
{
|
||||
var res = _sources.GetByUrl(url);
|
||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
||||
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||
|
||||
var htmlClient = new HtmlPageReader(new HtmlPageReaderOptions
|
||||
{
|
||||
@ -115,7 +116,7 @@ public class SourcesController : ControllerBase
|
||||
});
|
||||
htmlClient.Parse();
|
||||
|
||||
var item = _sources.New(new SourceModel
|
||||
var item = _sources.New(new SourceEntity
|
||||
{
|
||||
Site = SourceTypes.YouTube,
|
||||
Type = SourceTypes.YouTube,
|
||||
@ -127,11 +128,11 @@ public class SourcesController : ControllerBase
|
||||
YoutubeId = htmlClient.Data.Header.YoutubeChannelID ?? ""
|
||||
});
|
||||
|
||||
_icons.New(new IconModel
|
||||
_icons.New(new IconEntity()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FileName = htmlClient.Data.Header.Image,
|
||||
SourceId = item.ID
|
||||
SourceId = item.Id
|
||||
});
|
||||
|
||||
return SourceDto.Convert(item);
|
||||
@ -141,9 +142,9 @@ public class SourcesController : ControllerBase
|
||||
public SourceDto NewTwitch(string name)
|
||||
{
|
||||
var res = _sources.GetByNameAndType(name, SourceTypes.Twitch);
|
||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
||||
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||
|
||||
var item = _sources.New(new SourceModel
|
||||
var item = _sources.New(new SourceEntity
|
||||
{
|
||||
Site = SourceTypes.Twitch,
|
||||
Type = SourceTypes.Twitch,
|
||||
@ -162,7 +163,7 @@ public class SourcesController : ControllerBase
|
||||
//if (!url.Contains("github.com")) return new SourceDto();
|
||||
|
||||
var res = _sources.GetByUrl(url);
|
||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
||||
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||
|
||||
var slice = url.Split('/');
|
||||
|
||||
@ -172,7 +173,7 @@ public class SourcesController : ControllerBase
|
||||
});
|
||||
pageReader.Parse();
|
||||
|
||||
var item = _sources.New(new SourceModel
|
||||
var item = _sources.New(new SourceEntity
|
||||
{
|
||||
Site = SourceTypes.CodeProject,
|
||||
Type = SourceTypes.CodeProject,
|
||||
@ -183,11 +184,11 @@ public class SourcesController : ControllerBase
|
||||
Tags = $"{slice[2]},{slice[3]},{slice[4]}"
|
||||
});
|
||||
|
||||
_icons.New(new IconModel
|
||||
_icons.New(new IconEntity()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FileName = pageReader.Data.Header.Image,
|
||||
SourceId = item.ID
|
||||
SourceId = item.Id
|
||||
});
|
||||
|
||||
return SourceDto.Convert(item);
|
||||
@ -196,7 +197,7 @@ public class SourcesController : ControllerBase
|
||||
[HttpGet("{id}")]
|
||||
public SourceDto GetById(Guid id)
|
||||
{
|
||||
var item = _sources.GetByID(id);
|
||||
var item = _sources.GetById(id);
|
||||
return SourceDto.Convert(item);
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ public class SubscriptionsController : ControllerBase
|
||||
public SubscriptionDetailsDto GetDetailsById(Guid id)
|
||||
{
|
||||
var sub = _subscription.GetById(id);
|
||||
var webhook = _discord.GetByID(sub.DiscordWebHookId);
|
||||
var source = _sources.GetByID(sub.SourceId);
|
||||
var webhook = _discord.GetById(sub.DiscordWebHookId);
|
||||
var source = _sources.GetById(sub.SourceId);
|
||||
|
||||
return SubscriptionDetailsDto.Convert(sub, source, webhook);
|
||||
}
|
||||
@ -82,11 +82,11 @@ public class SubscriptionsController : ControllerBase
|
||||
var exists = _subscription.GetByWebhookAndSource(discordId, sourceId);
|
||||
if (exists.Id != Guid.Empty) return SubscriptionDto.Convert(exists);
|
||||
|
||||
var discord = _discord.GetByID(discordId);
|
||||
if (discord.ID == Guid.Empty) return new BadRequestResult();
|
||||
var discord = _discord.GetById(discordId);
|
||||
if (discord.Id == Guid.Empty) return new BadRequestResult();
|
||||
|
||||
var source = _sources.GetByID(sourceId);
|
||||
if (source.ID == Guid.Empty) return new BadRequestResult();
|
||||
var source = _sources.GetById(sourceId);
|
||||
if (source.Id == Guid.Empty) return new BadRequestResult();
|
||||
|
||||
var item = _subscription.New(new SubscriptionModel
|
||||
{
|
||||
@ -110,11 +110,11 @@ public class SubscriptionsController : ControllerBase
|
||||
var exists = _subscription.GetByWebhookAndSource(discordId, sourceId);
|
||||
if (exists.Id != Guid.Empty) return SubscriptionDto.Convert(exists);
|
||||
|
||||
var discord = _discord.GetByID(discordId);
|
||||
if (discord.ID == Guid.Empty) return new BadRequestResult();
|
||||
var discord = _discord.GetById(discordId);
|
||||
if (discord.Id == Guid.Empty) return new BadRequestResult();
|
||||
|
||||
var source = _sources.GetByID(sourceId);
|
||||
if (source.ID == Guid.Empty) return new BadRequestResult();
|
||||
var source = _sources.GetById(sourceId);
|
||||
if (source.Id == Guid.Empty) return new BadRequestResult();
|
||||
|
||||
var sub = _subscription.New(new SubscriptionModel
|
||||
{
|
||||
|
@ -30,61 +30,41 @@ public class ArticlesTable : IArticlesRepository
|
||||
_context = new DatabaseContext(conn);
|
||||
}
|
||||
|
||||
public async Task<List<ArticlesEntity>> ListAsync(int page = 0, int count = 25)
|
||||
public List<ArticlesEntity> List(int page = 0, int count = 25)
|
||||
{
|
||||
await using var context = new DatabaseContext(_connectionString);
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var query = context.Articles
|
||||
.Skip(page * count)
|
||||
.OrderBy(d => d.PubDate)
|
||||
.Take(25);
|
||||
Console.WriteLine(query.ToQueryString());
|
||||
await query.ToListAsync();
|
||||
return await query.ToListAsync();
|
||||
return query.ToList();
|
||||
}
|
||||
|
||||
public List<ArticlesEntity> List(int page = 0, int count = 25)
|
||||
public ArticlesEntity GetById(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var res = conn.Query<ArticlesEntity>(@"select * from Articles
|
||||
Order By PubDate Desc
|
||||
Offset @Page
|
||||
Fetch Next @Count Rows Only", new
|
||||
{
|
||||
Page = page * count,
|
||||
Count = count
|
||||
})
|
||||
.ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var query = context.Articles
|
||||
.FirstOrDefault(d => d.Id.Equals(id));
|
||||
query ??= new ArticlesEntity();
|
||||
return query;
|
||||
}
|
||||
|
||||
public ArticlesEntity GetByUrl(string url)
|
||||
{
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Articles.FirstOrDefault(d => d.Url!.Equals(url));
|
||||
res ??= new ArticlesEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public ArticlesModel GetById(Guid ID)
|
||||
public List<ArticlesEntity> ListBySourceId(Guid id, int page, int count)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var res = conn.Query<ArticlesModel>("select * from articles where ID = @ID", new { ID });
|
||||
if (res.Count() == 0) return new ArticlesModel();
|
||||
return res.First();
|
||||
}
|
||||
|
||||
public ArticlesModel GetByUrl(string url)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var res = conn.Query<ArticlesModel>("select * from articles where Url = @Url Limit 1", new { Url = url });
|
||||
if (res.Count() == 0) return new ArticlesModel();
|
||||
return res.First();
|
||||
}
|
||||
|
||||
public List<ArticlesModel> ListBySourceId(Guid id, int page, int count)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = @"Select * from articles
|
||||
where sourceid = @sourceid
|
||||
Offset @page
|
||||
Fetch next @count rows only";
|
||||
return conn.Query<ArticlesModel>(query, new
|
||||
{
|
||||
sourceid = id,
|
||||
page = page * count,
|
||||
count
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Articles
|
||||
.Skip(page * count)
|
||||
.Where(d => d.SourceId.Equals(id));
|
||||
return res.ToList();
|
||||
}
|
||||
|
||||
public ArticlesEntity New(ArticlesEntity model)
|
||||
@ -126,12 +106,17 @@ public class ArticlesTable : IArticlesRepository
|
||||
|
||||
public void DeleteAllBySourceId(Guid sourceId)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var res = conn.Execute("Delete from articles where sourceid = '@id'", new
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Articles
|
||||
.Where(d => d.SourceId.Equals(sourceId))
|
||||
.ToList();
|
||||
|
||||
foreach (var item in res)
|
||||
{
|
||||
sourceId
|
||||
});
|
||||
if (res == 0) throw new Exception($"No records where deleted that linked to SourceId = '{sourceId}'");
|
||||
context.Articles.Remove(item);
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
private IDbConnection OpenConnection(string connectionString)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Npgsql;
|
||||
@ -22,33 +23,28 @@ public class DiscordQueueTable : IDiscordQueueRepository
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void New(DiscordQueueModel model)
|
||||
public void New(DiscordQueueEntity model)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Insert into DiscordQueue(ID, ArticleId) Values (@id, @articleid);";
|
||||
conn.Execute(query, new
|
||||
{
|
||||
id = Guid.NewGuid(),
|
||||
articleid = model.ArticleID
|
||||
});
|
||||
model.Id = new Guid();
|
||||
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordQueue.Add(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Delete From DiscordQueue Where ID = @id;";
|
||||
conn.Execute(query, new
|
||||
{
|
||||
id = id
|
||||
});
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordQueue.FirstOrDefault(d => d.Id.Equals(id));
|
||||
res ??= new DiscordQueueEntity();
|
||||
context.DiscordQueue.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public List<DiscordQueueModel> List(int limit = 25)
|
||||
public List<DiscordQueueEntity> List(int limit = 25)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * from DiscordQueue LIMIT @limit;";
|
||||
return conn.Query<DiscordQueueModel>(query, new {
|
||||
limit = limit
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordQueue.Take(limit).ToList();
|
||||
return res;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using System.Data;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Npgsql;
|
||||
|
||||
namespace Newsbot.Collector.Database.Repositories;
|
||||
@ -22,103 +22,104 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
||||
_connectionString = connstr;
|
||||
}
|
||||
|
||||
public DiscordWebHookModel New(DiscordWebHookModel model)
|
||||
public DiscordWebhookEntity New(DiscordWebhookEntity model)
|
||||
{
|
||||
var uid = Guid.NewGuid();
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query =
|
||||
"Insert Into DiscordWebHooks (ID, Url, Server, Channel, Enabled) Values (@id, @url, @server, @channel, @enabled);";
|
||||
conn.Execute(query, new
|
||||
{
|
||||
id = uid,
|
||||
url = model.Url,
|
||||
server = model.Server,
|
||||
channel = model.Channel,
|
||||
enabled = model.Enabled
|
||||
});
|
||||
model.ID = uid;
|
||||
model.Id = new Guid();
|
||||
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
context.DiscordWebhooks.Add(model);
|
||||
context.SaveChanges();
|
||||
return model;
|
||||
}
|
||||
|
||||
public DiscordWebHookModel GetByID(Guid id)
|
||||
public DiscordWebhookEntity GetById(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * from DiscordWebHooks Where ID = @id LIMIT 1;";
|
||||
return conn.Query<DiscordWebHookModel>(query, new
|
||||
{
|
||||
id
|
||||
}).First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordWebhooks.FirstOrDefault(d => d.Id.Equals(id));
|
||||
res ??= new DiscordWebhookEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public DiscordWebHookModel GetByUrl(string url)
|
||||
public DiscordWebhookEntity GetByUrl(string url)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From DiscordWebHooks Where url = @url;";
|
||||
try
|
||||
{
|
||||
var res = conn.QueryFirst<DiscordWebHookModel>(query, new
|
||||
{
|
||||
url
|
||||
});
|
||||
return res;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new DiscordWebHookModel();
|
||||
}
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordWebhooks.FirstOrDefault(d => d.Url.Equals(url));
|
||||
res ??= new DiscordWebhookEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<DiscordWebHookModel> List(int page, int count = 25)
|
||||
public List<DiscordWebhookEntity> List(int page, int count = 25)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = @"Select * From DiscordWebHooks
|
||||
Offset @offset Fetch Next @count Rows Only;";
|
||||
return conn.Query<DiscordWebHookModel>(query, new
|
||||
{
|
||||
offset = page * count, count
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordWebhooks
|
||||
.Skip(page * count)
|
||||
.Take(count)
|
||||
.ToList();
|
||||
res ??= new List<DiscordWebhookEntity>();
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<DiscordWebHookModel> ListByServer(string server, int limit = 25)
|
||||
public List<DiscordWebhookEntity> ListByServer(string server, int limit = 25)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From DiscordWebHooks Where Server = @id Limit @limit;";
|
||||
return conn.Query<DiscordWebHookModel>(query, new
|
||||
{
|
||||
server, limit
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordWebhooks
|
||||
.Where(d => d.Server.Equals(server))
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
res ??= new List<DiscordWebhookEntity>();
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<DiscordWebHookModel> ListByServerAndChannel(string server, string channel, int limit = 25)
|
||||
public List<DiscordWebhookEntity> ListByServerAndChannel(string server, string channel, int limit = 25)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "SELECT * FROM DiscordWebHooks WHERE Server = @server and Channel = @channel Limit @limit;";
|
||||
return conn.Query<DiscordWebHookModel>(query, new
|
||||
{
|
||||
server,
|
||||
channel,
|
||||
limit
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.DiscordWebhooks
|
||||
.Where(s => s.Server.Equals(server))
|
||||
.Where(c => c.Channel.Equals(channel))
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
res ??= new List<DiscordWebhookEntity>();
|
||||
return res;
|
||||
}
|
||||
|
||||
public int Disable(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Update discordwebhooks Set Enabled = FALSE where ID = @id;";
|
||||
return conn.Execute(query, new
|
||||
var res = GetById(id);
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
|
||||
res.Enabled = true;
|
||||
|
||||
context.DiscordWebhooks.Update(res);
|
||||
try
|
||||
{
|
||||
id
|
||||
});
|
||||
context.SaveChanges();
|
||||
return 1;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed to update DiscordWebhook ID = {id}. {ex.Message}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int Enable(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Update discordwebhooks Set Enabled = TRUE where ID = @id;";
|
||||
return conn.Execute(query, new
|
||||
var res = GetById(id);
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
|
||||
res.Enabled = false;
|
||||
|
||||
context.DiscordWebhooks.Update(res);
|
||||
try
|
||||
{
|
||||
id
|
||||
});
|
||||
context.SaveChanges();
|
||||
return 1;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed to update DiscordWebhook ID = {id}. {ex.Message}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private IDbConnection OpenConnection(string connectionString)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Npgsql;
|
||||
@ -23,37 +24,29 @@ public class IconsTable : IIconsRepository
|
||||
_connectionString = connstr;
|
||||
}
|
||||
|
||||
public void New(IconModel model)
|
||||
public void New(IconEntity model)
|
||||
{
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
model.Id = Guid.NewGuid();
|
||||
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var q = @"Insert Into icons (id, filename, site, sourceid) values (@Id,@FileName, @Site, @SourceId)";
|
||||
conn.Execute(q, model);
|
||||
context.Icons.Add(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public IconModel GetById(Guid id)
|
||||
public IconEntity GetById(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From icons where ID = @id Limit 1;";
|
||||
var res = conn.Query<IconModel>(query, new
|
||||
{
|
||||
id
|
||||
});
|
||||
if (!res.Any()) return new IconModel();
|
||||
return res.First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Icons.FirstOrDefault(f => f.Id.Equals(id));
|
||||
res ??= new IconEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public IconModel GetBySourceId(Guid id)
|
||||
public IconEntity GetBySourceId(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From icons where sourceid = @id Limit 1;";
|
||||
var res = conn.Query<IconModel>(query, new
|
||||
{
|
||||
id
|
||||
});
|
||||
if (!res.Any()) return new IconModel();
|
||||
return res.First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Icons.FirstOrDefault(f => f.SourceId.Equals(id));
|
||||
res ??= new IconEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
private IDbConnection OpenConnection(string connectionString)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Npgsql;
|
||||
@ -23,157 +24,153 @@ public class SourcesTable : ISourcesRepository
|
||||
_connectionString = connstr;
|
||||
}
|
||||
|
||||
public SourceModel New(SourceModel model)
|
||||
public SourceEntity New(SourceEntity model)
|
||||
{
|
||||
model.ID = Guid.NewGuid();
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query =
|
||||
"Insert Into Sources (ID, Site, Name, Source, Type, Value, Enabled, Url, Tags, YoutubeId) Values (@id ,@site,@name,@source,@type,@value,@enabled,@url,@tags,@youtubeid);";
|
||||
conn.Execute(query, new
|
||||
model.Id = Guid.NewGuid();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
context.Sources.Add(model);
|
||||
try
|
||||
{
|
||||
id = model.ID,
|
||||
model.Site,
|
||||
model.Name,
|
||||
model.Source,
|
||||
model.Type,
|
||||
model.Value,
|
||||
model.Enabled,
|
||||
model.Url,
|
||||
model.Tags,
|
||||
model.YoutubeId
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed to save ");
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public SourceModel GetByID(Guid ID)
|
||||
public SourceEntity GetById(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From Sources where ID = @id Limit 1;";
|
||||
var res = conn.Query<SourceModel>(query, new
|
||||
{
|
||||
id = ID
|
||||
});
|
||||
if (res.Count() == 0) return new SourceModel();
|
||||
return res.First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources.FirstOrDefault(f => f.Id.Equals(id));
|
||||
res ??= new SourceEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public SourceModel GetByID(string ID)
|
||||
public SourceEntity GetById(string id)
|
||||
{
|
||||
var uid = Guid.Parse(ID);
|
||||
return GetByID(uid);
|
||||
var uid = Guid.Parse(id);
|
||||
return GetById(uid);
|
||||
}
|
||||
|
||||
public SourceModel GetByName(string Name)
|
||||
public SourceEntity GetByName(string name)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * from Sources where name = @name Limit 1;";
|
||||
var res = conn.Query<SourceModel>(query, new
|
||||
{
|
||||
name = Name
|
||||
});
|
||||
|
||||
if (res.Count() == 0) return new SourceModel();
|
||||
return res.First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources.FirstOrDefault(f => f.Name.Equals(name));
|
||||
res ??= new SourceEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public SourceModel GetByNameAndType(string name, string type)
|
||||
public SourceEntity GetByNameAndType(string name, string type)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * from Sources WHERE name = @name and type = @type;";
|
||||
var res = conn.Query<SourceModel>(query, new
|
||||
{
|
||||
name, type
|
||||
});
|
||||
|
||||
if (res.Count() == 0) return new SourceModel();
|
||||
return res.First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources
|
||||
.Where(f => f.Name.Equals(name))
|
||||
.FirstOrDefault(f => f.Type.Equals(type));
|
||||
res ??= new SourceEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public SourceModel GetByUrl(string url)
|
||||
public SourceEntity GetByUrl(string url)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * from Sources WHERE url = @url;";
|
||||
var res = conn.Query<SourceModel>(query, new
|
||||
{
|
||||
url
|
||||
});
|
||||
|
||||
if (res.ToList().Count == 0) return new SourceModel();
|
||||
|
||||
return res.First();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources
|
||||
.FirstOrDefault(f => f.Url.Equals(url));
|
||||
res ??= new SourceEntity();
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<SourceModel> List(int page = 0, int count = 25)
|
||||
public List<SourceEntity> List(int page = 0, int count = 100)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = @"Select * From Sources
|
||||
Offset @page
|
||||
Fetch Next @count Rows Only;";
|
||||
return conn.Query<SourceModel>(query, new
|
||||
{
|
||||
page = page * count, count
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources
|
||||
.Skip(page * count)
|
||||
.Take(count)
|
||||
.ToList();
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<SourceModel> ListBySource(string source, int limit = 25)
|
||||
public List<SourceEntity> ListBySource(string source, int page = 0, int limit = 25)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From Sources where Source = @source Limit @limit;";
|
||||
return conn.Query<SourceModel>(query, new
|
||||
{
|
||||
source, limit
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources
|
||||
.Where(f => f.Source.Equals(source))
|
||||
.Skip(page * limit)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<SourceModel> ListByType(string type, int limit = 25)
|
||||
public List<SourceEntity> ListByType(string type,int page = 0, int limit = 25)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Select * From Sources where Type = @type Limit @limit;";
|
||||
return conn.Query<SourceModel>(query, new
|
||||
{
|
||||
type, limit
|
||||
}).ToList();
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = context.Sources
|
||||
.Where(f => f.Type.Equals(type))
|
||||
.Skip(page * limit)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
return res;
|
||||
}
|
||||
|
||||
public int Disable(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Update Sources Set Enabled = FALSE where ID = @id;";
|
||||
return conn.Execute(query, new
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = GetById(id);
|
||||
res.Enabled = false;
|
||||
context.Sources.Update(res);
|
||||
try
|
||||
{
|
||||
id
|
||||
});
|
||||
context.SaveChanges();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int Enable(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Update Sources Set Enabled = TRUE where ID = @id;";
|
||||
return conn.Execute(query, new
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = GetById(id);
|
||||
res.Enabled = true;
|
||||
context.Sources.Update(res);
|
||||
try
|
||||
{
|
||||
id
|
||||
});
|
||||
context.SaveChanges();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Delete From sources where id = @id;";
|
||||
var res = conn.Execute(query, new
|
||||
{
|
||||
id
|
||||
});
|
||||
if (res == 0) throw new Exception("Nothing was deleted");
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = GetById(id);
|
||||
context.Sources.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public int UpdateYoutubeId(Guid id, string youtubeId)
|
||||
{
|
||||
using var conn = OpenConnection(_connectionString);
|
||||
var query = "Update Sources Set youtubeid = @youtubeId where ID = @id;";
|
||||
return conn.Execute(query, new
|
||||
using var context = new DatabaseContext(_connectionString);
|
||||
var res = GetById(id);
|
||||
res.YoutubeId = youtubeId;
|
||||
context.Sources.Update(res);
|
||||
try
|
||||
{
|
||||
id, youtubeId
|
||||
});
|
||||
context.SaveChanges();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private IDbConnection OpenConnection(string connectionString)
|
||||
|
@ -1,10 +1,11 @@
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Dto;
|
||||
|
||||
public class ArticleDetailsDto
|
||||
{
|
||||
public Guid ID { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public string[]? Tags { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? Url { get; set; }
|
||||
@ -19,14 +20,14 @@ public class ArticleDetailsDto
|
||||
|
||||
public SourceDto? Source { get; set; }
|
||||
|
||||
public static ArticleDetailsDto Convert(ArticlesModel article, SourceModel source)
|
||||
public static ArticleDetailsDto Convert(ArticlesEntity article, SourceEntity source)
|
||||
{
|
||||
return new ArticleDetailsDto
|
||||
{
|
||||
ID = article.ID,
|
||||
Id = article.Id,
|
||||
Tags = article.Tags.Split(','),
|
||||
Title = article.Title,
|
||||
Url = article.URL,
|
||||
Url = article.Url,
|
||||
PubDate = article.PubDate,
|
||||
Video = article.Video,
|
||||
VideoHeight = article.VideoHeight,
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Dto;
|
||||
|
||||
@ -10,11 +10,11 @@ public class DiscordWebHookDto
|
||||
public string? Channel { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public static DiscordWebHookDto Convert(DiscordWebHookModel model)
|
||||
public static DiscordWebHookDto Convert(DiscordWebhookEntity model)
|
||||
{
|
||||
return new DiscordWebHookDto
|
||||
{
|
||||
ID = model.ID,
|
||||
ID = model.Id,
|
||||
Url = model.Url,
|
||||
Server = model.Server,
|
||||
Channel = model.Channel,
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Net.NetworkInformation;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Dto;
|
||||
@ -16,10 +17,10 @@ public class SourceDto
|
||||
public string[]? Tags { get; set; }
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
public static SourceDto Convert(SourceModel model) {
|
||||
public static SourceDto Convert(SourceEntity model) {
|
||||
return new SourceDto
|
||||
{
|
||||
ID = model.ID,
|
||||
ID = model.Id,
|
||||
Site = model.Site,
|
||||
Name = model.Name,
|
||||
Source = model.Source,
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Dto;
|
||||
@ -10,8 +11,8 @@ public class SubscriptionDetailsDto
|
||||
public SourceDto? Source { get; set; }
|
||||
public DiscordWebHookDto? DiscordWebHook { get; set; }
|
||||
|
||||
public static SubscriptionDetailsDto Convert(SubscriptionModel subscription, SourceModel source,
|
||||
DiscordWebHookModel discord)
|
||||
public static SubscriptionDetailsDto Convert(SubscriptionModel subscription, SourceEntity source,
|
||||
DiscordWebhookEntity discord)
|
||||
{
|
||||
return new SubscriptionDetailsDto
|
||||
{
|
||||
|
@ -6,9 +6,9 @@ namespace Newsbot.Collector.Domain.Interfaces;
|
||||
public interface IArticlesRepository : ITableRepository
|
||||
{
|
||||
List<ArticlesEntity> List(int page, int count);
|
||||
List<ArticlesModel> ListBySourceId(Guid id, int page = 0, int count = 25);
|
||||
ArticlesModel GetById(Guid ID);
|
||||
ArticlesModel GetByUrl(string url);
|
||||
List<ArticlesEntity> ListBySourceId(Guid id, int page = 0, int count = 25);
|
||||
ArticlesEntity GetById(Guid id);
|
||||
ArticlesEntity GetByUrl(string url);
|
||||
ArticlesEntity New(ArticlesEntity model);
|
||||
void DeleteAllBySourceId(Guid sourceId);
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Interfaces;
|
||||
|
||||
public interface IDiscordQueueRepository
|
||||
{
|
||||
void New(DiscordQueueModel model);
|
||||
void New(DiscordQueueEntity model);
|
||||
void Delete(Guid id);
|
||||
List<DiscordQueueModel> List(int limit);
|
||||
List<DiscordQueueEntity> List(int limit);
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Interfaces;
|
||||
|
||||
public interface IDiscordWebHooksRepository
|
||||
{
|
||||
DiscordWebHookModel New(DiscordWebHookModel model);
|
||||
DiscordWebhookEntity New(DiscordWebhookEntity model);
|
||||
|
||||
DiscordWebHookModel GetByID(Guid id);
|
||||
DiscordWebHookModel GetByUrl(string url);
|
||||
DiscordWebhookEntity GetById(Guid id);
|
||||
DiscordWebhookEntity GetByUrl(string url);
|
||||
|
||||
List<DiscordWebHookModel> List(int page, int count = 25);
|
||||
List<DiscordWebHookModel> ListByServer(string server, int limit);
|
||||
List<DiscordWebHookModel> ListByServerAndChannel(string server, string channel, int limit);
|
||||
List<DiscordWebhookEntity> List(int page, int count = 25);
|
||||
List<DiscordWebhookEntity> ListByServer(string server, int limit);
|
||||
List<DiscordWebhookEntity> ListByServerAndChannel(string server, string channel, int limit);
|
||||
|
||||
int Disable(Guid id);
|
||||
int Enable(Guid id);
|
||||
|
@ -1,11 +1,11 @@
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Interfaces;
|
||||
|
||||
public interface IIconsRepository
|
||||
{
|
||||
public void New(IconModel model);
|
||||
public void New(IconEntity model);
|
||||
|
||||
public IconModel GetById(Guid id);
|
||||
public IconModel GetBySourceId(Guid id);
|
||||
public IconEntity GetById(Guid id);
|
||||
public IconEntity GetBySourceId(Guid id);
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
namespace Newsbot.Collector.Domain.Interfaces;
|
||||
|
||||
public interface ISourcesRepository
|
||||
{
|
||||
public SourceModel New(SourceModel model);
|
||||
public SourceModel GetByID(Guid ID);
|
||||
public SourceModel GetByID(string ID);
|
||||
public SourceModel GetByName(string name);
|
||||
public SourceModel GetByNameAndType(string name, string type);
|
||||
SourceModel GetByUrl(string url);
|
||||
public List<SourceModel> List(int page, int count);
|
||||
public List<SourceModel> ListBySource(string source, int limit);
|
||||
public List<SourceModel> ListByType(string type, int limit = 25);
|
||||
public SourceEntity New(SourceEntity model);
|
||||
public SourceEntity GetById(Guid id);
|
||||
public SourceEntity GetById(string id);
|
||||
public SourceEntity GetByName(string name);
|
||||
public SourceEntity GetByNameAndType(string name, string type);
|
||||
SourceEntity GetByUrl(string url);
|
||||
public List<SourceEntity> List(int page, int count);
|
||||
public List<SourceEntity> ListBySource(string source,int page, int limit);
|
||||
public List<SourceEntity> ListByType(string type,int page, int limit = 25);
|
||||
public int Disable(Guid id);
|
||||
public int Enable(Guid id);
|
||||
public void Delete(Guid id);
|
||||
|
@ -3,6 +3,7 @@ using System.ServiceModel.Syndication;
|
||||
using System.Xml;
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Consts;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Models.Config;
|
||||
@ -60,10 +61,10 @@ public class CodeProjectWatcherJob
|
||||
|
||||
private void Execute()
|
||||
{
|
||||
var sources = _source.ListByType(SourceTypes.CodeProject);
|
||||
var sources = _source.ListByType(SourceTypes.CodeProject, 0, 100);
|
||||
|
||||
// query sources for things to pull
|
||||
var items = new List<ArticlesModel>();
|
||||
var items = new List<ArticlesEntity>();
|
||||
|
||||
foreach (var source in sources)
|
||||
{
|
||||
@ -74,14 +75,14 @@ public class CodeProjectWatcherJob
|
||||
foreach (var item in items)
|
||||
{
|
||||
_articles.New(item);
|
||||
_queue.New(new DiscordQueueModel
|
||||
_queue.New(new DiscordQueueEntity()
|
||||
{
|
||||
ArticleID = item.ID
|
||||
ArticleId = item.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ArticlesModel> CheckForReleases(SourceModel source)
|
||||
public IEnumerable<ArticlesEntity> CheckForReleases(SourceEntity source)
|
||||
{
|
||||
var url = new Uri(source.Url);
|
||||
var links = new List<string>
|
||||
@ -110,10 +111,10 @@ public class CodeProjectWatcherJob
|
||||
url.AbsoluteUri);
|
||||
}
|
||||
|
||||
return new List<ArticlesModel>();
|
||||
return new List<ArticlesEntity>();
|
||||
}
|
||||
|
||||
public IEnumerable<ArticlesModel> CheckForCommits(SourceModel source)
|
||||
public IEnumerable<ArticlesEntity> CheckForCommits(SourceEntity source)
|
||||
{
|
||||
var url = new Uri(source.Url);
|
||||
var links = new List<string>
|
||||
@ -136,19 +137,19 @@ public class CodeProjectWatcherJob
|
||||
url.AbsoluteUri);
|
||||
}
|
||||
|
||||
return new List<ArticlesModel>();
|
||||
return new List<ArticlesEntity>();
|
||||
}
|
||||
|
||||
private IEnumerable<ArticlesModel> ProcessFeed(IEnumerable<SyndicationItem> feed, SourceModel source,
|
||||
private IEnumerable<ArticlesEntity> ProcessFeed(IEnumerable<SyndicationItem> feed, SourceEntity source,
|
||||
bool isRelease, bool isCommit)
|
||||
{
|
||||
var items = new List<ArticlesModel>();
|
||||
var items = new List<ArticlesEntity>();
|
||||
|
||||
foreach (var item in feed)
|
||||
{
|
||||
var itemUrl = item.Links[0].Uri.AbsoluteUri;
|
||||
var exits = _articles.GetByUrl(itemUrl);
|
||||
if (exits.ID != Guid.Empty) continue;
|
||||
if (exits.Id != Guid.Empty) continue;
|
||||
|
||||
var parser = new HtmlPageReader(new HtmlPageReaderOptions
|
||||
{
|
||||
@ -156,12 +157,12 @@ public class CodeProjectWatcherJob
|
||||
});
|
||||
parser.Parse();
|
||||
|
||||
var a = new ArticlesModel
|
||||
var a = new ArticlesEntity
|
||||
{
|
||||
SourceID = source.ID,
|
||||
SourceId = source.Id,
|
||||
Tags = source.Tags,
|
||||
Title = item.Title.Text,
|
||||
URL = itemUrl,
|
||||
Url = itemUrl,
|
||||
PubDate = item.LastUpdatedTime.DateTime,
|
||||
Thumbnail = parser.Data.Header.Image,
|
||||
Description = item.Title.Text,
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Services.Notifications.Discord;
|
||||
@ -83,45 +84,44 @@ public class DiscordNotificationJob
|
||||
_logger.Information($"{JobName} - Loop has been completed.");
|
||||
}
|
||||
|
||||
public void ProcessQueueItem(DiscordQueueModel request)
|
||||
public void ProcessQueueItem(DiscordQueueEntity request)
|
||||
{
|
||||
_logger.Debug($"{JobName} - Processing {request.ID}");
|
||||
_logger.Debug($"{JobName} - Processing {request.Id}");
|
||||
// Get all details on the article in the queue
|
||||
var articleDetails = _article.GetById(request.ArticleID);
|
||||
var articleDetails = _article.GetById(request.ArticleId);
|
||||
|
||||
// Get the details of the source
|
||||
var sourceDetails = _sources.GetByID(articleDetails.SourceID);
|
||||
if (sourceDetails.ID == Guid.Empty)
|
||||
var sourceDetails = _sources.GetById(articleDetails.SourceId);
|
||||
if (sourceDetails.Id == Guid.Empty)
|
||||
{
|
||||
_logger.Error(
|
||||
$"{JobName} - Article ({articleDetails.ID}) was linked to a empty Source ID. Removing from the queue.");
|
||||
_queue.Delete(request.ID);
|
||||
$"{JobName} - Article ({articleDetails.Id}) was linked to a empty Source ID. Removing from the queue.");
|
||||
_queue.Delete(request.Id);
|
||||
return;
|
||||
}
|
||||
|
||||
var sourceIcon = new IconModel();
|
||||
var sourceIcon = new IconEntity();
|
||||
try
|
||||
{
|
||||
sourceIcon = _icons.GetBySourceId(sourceDetails.ID);
|
||||
sourceIcon = _icons.GetBySourceId(sourceDetails.Id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_logger.Warning("{JobName} - Source ID \'{SourceDetailsId}\' is missing an icon", JobName,
|
||||
sourceDetails.ID);
|
||||
sourceDetails.Id);
|
||||
}
|
||||
|
||||
// Find all the subscriptions for that source
|
||||
var allSubscriptions = _subs.ListBySourceID(sourceDetails.ID);
|
||||
var allSubscriptions = _subs.ListBySourceID(sourceDetails.Id);
|
||||
|
||||
foreach (var sub in allSubscriptions)
|
||||
SendSubscriptionNotification(request.ID, articleDetails, sourceDetails, sourceIcon, sub);
|
||||
SendSubscriptionNotification(request.Id, articleDetails, sourceDetails, sourceIcon, sub);
|
||||
|
||||
_logger.Debug("{JobName} - Removing {RequestId} from the queue", JobName, request.ID);
|
||||
_queue.Delete(request.ID);
|
||||
_logger.Debug("{JobName} - Removing {RequestId} from the queue", JobName, request.Id);
|
||||
_queue.Delete(request.Id);
|
||||
}
|
||||
|
||||
public void SendSubscriptionNotification(Guid requestId, ArticlesModel articleDetails, SourceModel sourceDetails,
|
||||
IconModel sourceIcon, SubscriptionModel sub)
|
||||
public void SendSubscriptionNotification(Guid requestId, ArticlesEntity articleDetails, SourceEntity sourceDetails, IconEntity sourceIcon, SubscriptionModel sub)
|
||||
{
|
||||
// Check if the subscription code flags
|
||||
// If the article is a code commit and the subscription does not want them, skip.
|
||||
@ -131,7 +131,7 @@ public class DiscordNotificationJob
|
||||
if (articleDetails.CodeIsRelease && !sub.CodeAllowReleases) throw new MessageTypeNotRequestedException("Message was a code release and was not requested by the subscription");
|
||||
|
||||
// find the discord webhooks we need to post to
|
||||
var discordDetails = _webhook.GetByID(sub.DiscordWebHookId);
|
||||
var discordDetails = _webhook.GetById(sub.DiscordWebHookId);
|
||||
if (discordDetails.Enabled == false) return;
|
||||
|
||||
var client = new DiscordWebhookClient(discordDetails.Url);
|
||||
@ -143,15 +143,15 @@ public class DiscordNotificationJob
|
||||
{
|
||||
_logger.Error("Failed to post message to Discord. {ErrorMessage}", e.Message);
|
||||
_logger.Debug("Queue Record: {RequestId}", requestId);
|
||||
_logger.Debug("Article: {ArticleDetailsId}", articleDetails.ID);
|
||||
_logger.Debug("Source: {SourceDetailsId}", sourceDetails.ID);
|
||||
_logger.Debug("Article: {ArticleDetailsId}", articleDetails.Id);
|
||||
_logger.Debug("Source: {SourceDetailsId}", sourceDetails.Id);
|
||||
_logger.Debug("Subscription: {SubId}", sub.Id);
|
||||
}
|
||||
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
|
||||
public DiscordMessage GenerateDiscordMessage(SourceModel source, ArticlesModel article, IconModel icon)
|
||||
public DiscordMessage GenerateDiscordMessage(SourceEntity source, ArticlesEntity article, IconEntity icon)
|
||||
{
|
||||
var embed = new DiscordMessageEmbed
|
||||
{
|
||||
@ -172,13 +172,13 @@ public class DiscordNotificationJob
|
||||
new()
|
||||
{
|
||||
Name = "Link",
|
||||
Value = article.URL,
|
||||
Value = article.Url,
|
||||
Inline = false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (article.URL is not null && article.URL != "") embed.Url = article.URL;
|
||||
if (article.Url is not null && article.Url != "") embed.Url = article.Url;
|
||||
|
||||
if (article.Thumbnail != "")
|
||||
embed.Image = new DiscordMessageEmbedImage
|
||||
|
@ -2,6 +2,7 @@ using System.ServiceModel.Syndication;
|
||||
using System.Xml;
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Consts;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Models.Config;
|
||||
@ -56,17 +57,17 @@ public class RssWatcherJob
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
var articles = new List<ArticlesModel>();
|
||||
var articles = new List<ArticlesEntity>();
|
||||
|
||||
_logger.Information($"{JobName} - Requesting sources");
|
||||
var sources = _source.ListByType(SourceTypes.Rss);
|
||||
_logger.Information($"{JobName} - Got {sources.Count} back");
|
||||
var sources = _source.ListByType(SourceTypes.Rss, 0, 100);
|
||||
_logger.Information("{JobName} - Got {SourcesCount} back", JobName, sources.Count);
|
||||
|
||||
foreach (var source in sources)
|
||||
{
|
||||
_logger.Information($"{JobName} - Starting to process '{source.Name}'");
|
||||
_logger.Information("{JobName} - Starting to process \'{SourceName}\'", JobName, source.Name);
|
||||
_logger.Information($"{JobName} - Starting to request feed to be processed");
|
||||
var results = Collect(source.Url, source.ID);
|
||||
var results = Collect(source.Url, source.Id);
|
||||
|
||||
_logger.Information($"{JobName} - Collected {results.Count} posts");
|
||||
articles.AddRange(results);
|
||||
@ -78,9 +79,9 @@ public class RssWatcherJob
|
||||
_logger.Information($"{JobName} - Done!");
|
||||
}
|
||||
|
||||
public List<ArticlesModel> Collect(string url, Guid sourceId, int sleep = 3000)
|
||||
public List<ArticlesEntity> Collect(string url, Guid sourceId, int sleep = 3000)
|
||||
{
|
||||
var collectedPosts = new List<ArticlesModel>();
|
||||
var collectedPosts = new List<ArticlesEntity>();
|
||||
|
||||
using var reader = XmlReader.Create(url);
|
||||
var feed = SyndicationFeed.Load(reader);
|
||||
@ -99,15 +100,15 @@ public class RssWatcherJob
|
||||
});
|
||||
meta.Parse();
|
||||
|
||||
var article = new ArticlesModel
|
||||
var article = new ArticlesEntity
|
||||
{
|
||||
Title = post.Title.Text,
|
||||
Tags = FetchTags(post),
|
||||
URL = articleUrl,
|
||||
Url = articleUrl,
|
||||
PubDate = post.PublishDate.DateTime,
|
||||
Thumbnail = meta.Data.Header.Image,
|
||||
Description = meta.Data.Header.Description,
|
||||
SourceID = sourceId
|
||||
SourceId = sourceId
|
||||
};
|
||||
|
||||
collectedPosts.Add(article);
|
||||
@ -119,20 +120,20 @@ public class RssWatcherJob
|
||||
return collectedPosts;
|
||||
}
|
||||
|
||||
public void UpdateDatabase(List<ArticlesModel> items)
|
||||
public void UpdateDatabase(List<ArticlesEntity> items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.URL is null)
|
||||
if (item.Url is null)
|
||||
{
|
||||
Log.Warning("RSS Watcher collected a blank url and was skipped.");
|
||||
Log.Warning("RSS Watcher collected a blank url and was skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
var p = _articles.New(item);
|
||||
_queue.New(new DiscordQueueModel
|
||||
_queue.New(new DiscordQueueEntity
|
||||
{
|
||||
ArticleID = p.ID
|
||||
ArticleId = p.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -140,7 +141,7 @@ public class RssWatcherJob
|
||||
private bool IsThisUrlKnown(string url)
|
||||
{
|
||||
var isKnown = _articles.GetByUrl(url);
|
||||
if (isKnown.URL == url) return true;
|
||||
if (isKnown.Url == url) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ using System.ServiceModel.Syndication;
|
||||
using System.Xml;
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Consts;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Services.HtmlParser;
|
||||
@ -66,11 +67,11 @@ public class YoutubeWatcherJob
|
||||
if (channelId == "")
|
||||
{
|
||||
channelId = GetChannelId(source.Url);
|
||||
_source.UpdateYoutubeId(source.ID, channelId);
|
||||
_source.UpdateYoutubeId(source.Id, channelId);
|
||||
}
|
||||
|
||||
// Make sure we have a Icon for the channel
|
||||
var icon = _icons.GetBySourceId(source.ID);
|
||||
var icon = _icons.GetBySourceId(source.Id);
|
||||
if (icon.Id == Guid.Empty) Console.WriteLine("I was triggered :V");
|
||||
|
||||
_logger.Information($"{JobName} - Checking '{source.Name}'");
|
||||
@ -82,9 +83,9 @@ public class YoutubeWatcherJob
|
||||
{
|
||||
_logger.Debug($"{JobName} - {video.AuthorName} '{video.Title}' was found");
|
||||
_articles.New(video);
|
||||
_queue.New(new DiscordQueueModel
|
||||
_queue.New(new DiscordQueueEntity
|
||||
{
|
||||
ArticleID = video.ID
|
||||
ArticleId = video.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -109,9 +110,9 @@ public class YoutubeWatcherJob
|
||||
return id;
|
||||
}
|
||||
|
||||
private List<ArticlesModel> CheckFeed(string url, SourceModel source)
|
||||
private List<ArticlesEntity> CheckFeed(string url, SourceEntity source)
|
||||
{
|
||||
var videos = new List<ArticlesModel>();
|
||||
var videos = new List<ArticlesEntity>();
|
||||
|
||||
using var reader = XmlReader.Create(url);
|
||||
var feed = SyndicationFeed.Load(reader);
|
||||
@ -126,17 +127,17 @@ public class YoutubeWatcherJob
|
||||
});
|
||||
videoDetails.Parse();
|
||||
|
||||
var article = new ArticlesModel
|
||||
var article = new ArticlesEntity
|
||||
{
|
||||
//Todo add the icon
|
||||
AuthorName = post.Authors[0].Name,
|
||||
Title = post.Title.Text,
|
||||
Tags = FetchTags(post),
|
||||
URL = articleUrl,
|
||||
Url = articleUrl,
|
||||
PubDate = post.PublishDate.DateTime,
|
||||
Thumbnail = videoDetails.Data.Header.Image,
|
||||
Description = videoDetails.Data.Header.Description,
|
||||
SourceID = source.ID,
|
||||
SourceId = source.Id,
|
||||
Video = "true"
|
||||
};
|
||||
|
||||
@ -151,7 +152,7 @@ public class YoutubeWatcherJob
|
||||
private bool IsThisUrlKnown(string url)
|
||||
{
|
||||
var isKnown = _articles.GetByUrl(url);
|
||||
if (isKnown.URL == url) return true;
|
||||
if (isKnown.Url == url) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newsbot.Collector.Domain.Consts;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Domain.Models.Config;
|
||||
using Newsbot.Collector.Services.Jobs;
|
||||
@ -18,9 +19,9 @@ public class CodeProjectWatcherJobTests
|
||||
FeaturePullCommits = true,
|
||||
FeaturePullReleases = true
|
||||
});
|
||||
var results = client.CheckForReleases(new SourceModel
|
||||
var results = client.CheckForReleases(new SourceEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
Url = "https://github.com/jtom38/dvb",
|
||||
Type = SourceTypes.CodeProject,
|
||||
Site = SourceTypes.CodeProject,
|
||||
@ -44,9 +45,9 @@ public class CodeProjectWatcherJobTests
|
||||
FeaturePullCommits = true,
|
||||
FeaturePullReleases = true
|
||||
});
|
||||
var results = client.CheckForReleases(new SourceModel
|
||||
var results = client.CheckForReleases(new SourceEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
Url = "https://github.com/python/cpython",
|
||||
Type = SourceTypes.CodeProject,
|
||||
Site = SourceTypes.CodeProject,
|
||||
@ -70,9 +71,9 @@ public class CodeProjectWatcherJobTests
|
||||
FeaturePullCommits = true,
|
||||
FeaturePullReleases = true
|
||||
});
|
||||
var results = client.CheckForCommits(new SourceModel
|
||||
var results = client.CheckForCommits(new SourceEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
Url = "https://github.com/jtom38/dvb",
|
||||
Type = SourceTypes.CodeProject,
|
||||
Site = SourceTypes.CodeProject,
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
using Newsbot.Collector.Services.Jobs;
|
||||
using Newsbot.Collector.Services.Notifications.Discord;
|
||||
@ -13,9 +14,9 @@ public class DiscordNotificationJobTest
|
||||
var webhookClient = new DiscordWebhookClient(uri);
|
||||
|
||||
var client = new DiscordNotificationJob();
|
||||
var msg = client.GenerateDiscordMessage(new SourceModel
|
||||
var msg = client.GenerateDiscordMessage(new SourceEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
Site = "Unit Test",
|
||||
Source = "placeholder",
|
||||
Type = "a",
|
||||
@ -24,17 +25,17 @@ public class DiscordNotificationJobTest
|
||||
Url = "https://github.com",
|
||||
Tags = "Unit, Testing"
|
||||
},
|
||||
new ArticlesModel
|
||||
new ArticlesEntity
|
||||
{
|
||||
Tags = "more,unit,testing",
|
||||
Title = "Nope not real",
|
||||
URL = "https://github.com/jtom38",
|
||||
Url = "https://github.com/jtom38",
|
||||
PubDate = DateTime.Now,
|
||||
Thumbnail = "https://cdn.arstechnica.net/wp-content/uploads/2023/03/GettyImages-944827400-800x534.jpg",
|
||||
Description = "Please work",
|
||||
AuthorName = "No one knows"
|
||||
},
|
||||
new IconModel
|
||||
new IconEntity()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FileName = "https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png"
|
||||
@ -50,11 +51,11 @@ public class DiscordNotificationJobTest
|
||||
{
|
||||
client.SendSubscriptionNotification(
|
||||
new Guid(),
|
||||
new ArticlesModel
|
||||
new ArticlesEntity
|
||||
{
|
||||
Tags = "more,unit,testing",
|
||||
Title = "Nope not real",
|
||||
URL = "https://github.com/jtom38",
|
||||
Url = "https://github.com/jtom38",
|
||||
PubDate = DateTime.Now,
|
||||
Thumbnail =
|
||||
"https://cdn.arstechnica.net/wp-content/uploads/2023/03/GettyImages-944827400-800x534.jpg",
|
||||
@ -62,9 +63,9 @@ public class DiscordNotificationJobTest
|
||||
AuthorName = "No one knows",
|
||||
CodeIsCommit = true
|
||||
},
|
||||
new SourceModel
|
||||
new SourceEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
Site = "Unit Test",
|
||||
Source = "placeholder",
|
||||
Type = "a",
|
||||
@ -73,7 +74,7 @@ public class DiscordNotificationJobTest
|
||||
Url = "https://github.com",
|
||||
Tags = "Unit, Testing"
|
||||
},
|
||||
new IconModel
|
||||
new IconEntity()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FileName = "https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png"
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
namespace Newsbot.Collector.Tests.Tables;
|
||||
@ -23,7 +24,7 @@ public class ArticlesTableTests
|
||||
{
|
||||
var cfg = GetConfiguration();
|
||||
var client = new ArticlesTable(cfg);
|
||||
client.List();
|
||||
client.List(0, 25);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -34,7 +35,7 @@ public class ArticlesTableTests
|
||||
var cfg = GetConfiguration();
|
||||
var client = new ArticlesTable(cfg);
|
||||
var res = client.GetById(uid);
|
||||
if (!res.ID.Equals(uid))
|
||||
if (!res.Id.Equals(uid))
|
||||
{
|
||||
Assert.Fail("Incorrect record or not found");
|
||||
}
|
||||
@ -45,14 +46,14 @@ public class ArticlesTableTests
|
||||
{
|
||||
var cfg = GetConfiguration();
|
||||
var client = new ArticlesTable(cfg);
|
||||
var m = new ArticlesModel
|
||||
var m = new ArticlesEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
SourceID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
SourceId = Guid.NewGuid(),
|
||||
Tags = "thing, thing2",
|
||||
Title = "Unit Testing!",
|
||||
URL = "https://google.com",
|
||||
PubDate = DateTime.Now.ToLocalTime(),
|
||||
Url = "https://google.com",
|
||||
PubDate = DateTime.Now.ToUniversalTime(),
|
||||
};
|
||||
client.New(m);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Newsbot.Collector.Database.Repositories;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Models;
|
||||
|
||||
namespace Newsbot.Collector.Tests.Tables;
|
||||
@ -9,9 +10,9 @@ public class SourcesTableTests
|
||||
public void NewRecordTest()
|
||||
{
|
||||
var client = new SourcesTable("");
|
||||
var m = new SourceModel
|
||||
var m = new SourceEntity
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Id = Guid.NewGuid(),
|
||||
Site = "Testing",
|
||||
Name = "Testing",
|
||||
Source = "Testing",
|
||||
|
Loading…
Reference in New Issue
Block a user