Reworking database implementation

This commit is contained in:
Max 2023-05-27 00:32:05 +02:00
parent 9c6c55316f
commit 2355da58b2
3 changed files with 24 additions and 20 deletions

View File

@ -28,10 +28,17 @@ namespace SharpRss.Services
}
public async Task<bool> CreateGroupAsync(GroupModel group) => await _dbService.SetGroupAsync(group);
public async Task<HashSet<GroupModel>> GetGroupsAsync() => await _dbService.GetGroupsAsync();
public async Task<bool> AddFeed(string rssUrl, GroupModel? group = null)
//TODO: Need to rework this implementation!!!
/*public async Task<bool> FetchFeeds(string[]? rssUrls, GroupModel? group = null)
{
bool result = false;
if (rssUrls == null) return result;
HashSet<Feed> fetchedFeeds = new HashSet<Feed>();
foreach (var rssUrl in rssUrls)
{
fetchedFeeds.Add(await FetchFeed(rssUrl));
}
Feed fetched = await FetchFeed(rssUrl);
if (fetched == null)
@ -56,7 +63,7 @@ namespace SharpRss.Services
if (await AddFeedItems(fetched.Items, dbFeed) == 0)
Log.Warning("No feed items added to feed: {FeedUrl}", dbFeed.Url);
return result;
}
}*/
public async Task<HashSet<FeedModel>> GetFeedsAsync(string? groupId = null) => await _dbService.GetFeedsAsync(groupId);
public async Task<HashSet<FeedModel>> GetUngroupedFeedsAsync() => await _dbService.GetFeedsAsync("");
@ -108,24 +115,22 @@ namespace SharpRss.Services
groupRes = await CreateGroupAsync(new GroupModel() { Name = "News" });
groupRes = await CreateGroupAsync(new GroupModel() { Name = "Tech" });
groupRes = await CreateGroupAsync(new GroupModel() { Name = "Science" });*/
/*var groups = await GetGroupsAsync();
/*Log.Verbose("Fetching feeds...");
var groups = await GetGroupsAsync();
GroupModel testGroup = groups.Single(x => x.Name == "Test");
await Task.Run(async () =>
try
{
try
{
var res = await AddFeed("http://fedoramagazine.org/feed/", testGroup);
res = await AddFeed("https://www.nasa.gov/rss/dyn/breaking_news.rss", testGroup);
res = await AddFeed("https://journals.plos.org/plosone/feed/atom", testGroup);
res = await AddFeed("https://itsfoss.com/feed", testGroup);
res = await AddFeed("https://advisories.ncsc.nl/rss/advisories", testGroup);
}
catch (Exception e)
{
Log.Error(e, "Error fetching feeds!");
throw;
}
});*/
var res = await AddFeed("http://fedoramagazine.org/feed/", testGroup);
res = await AddFeed("https://www.nasa.gov/rss/dyn/breaking_news.rss", testGroup);
res = await AddFeed("https://journals.plos.org/plosone/feed/atom", testGroup);
res = await AddFeed("https://itsfoss.com/feed", testGroup);
res = await AddFeed("https://advisories.ncsc.nl/rss/advisories", testGroup);
}
catch (Exception e)
{
Log.Error(e, "Error fetching feeds!");
throw;
}*/
}
public void Dispose()

View File

@ -53,7 +53,6 @@
{
var fItems = await _rssService.GetFeedItemsAsync(Fid);
items = fItems.Select(x => FeedItemData.FromModel(x)).OrderBy(x => x.PublishingDate).Reverse().ToHashSet();
_isLoading = false;
}
else if (Gid != null)
{

Binary file not shown.