Reworking db models from Argotic

This commit is contained in:
Max Holleman 2023-06-02 11:56:48 +02:00
parent 4ef3b58a20
commit 5a1f350caf
3 changed files with 14 additions and 7 deletions

View File

@ -143,7 +143,7 @@ namespace SharpRss
FeedModel? feed = null; FeedModel? feed = null;
await using SqliteConnection dbc = new SqliteConnection(ConnectionString); await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
dbc.Open(); dbc.Open();
await using SqliteCommand cmd = new SqliteCommand($"INSERT OR REPLACE INTO {FeedTable} (url, title, group_id, feed_type, description, language, copyright, date_added, last_updated, image_url, original_document) VALUES (@url, @title, @groupId, @feedType, @description, @language, @copyright, @dateAdded), @lastUpdated, @imageUrl, @originalDoc); SELECT * FROM {FeedTable} WHERE url=@url", dbc) await using SqliteCommand cmd = new SqliteCommand($"INSERT OR REPLACE INTO {FeedTable} (url, title, group_id, feed_type, description, language, copyright, date_added, last_updated, image_url, original_document) VALUES (@url, @title, @groupId, @feedType, @description, @language, @copyright, @dateAdded, @lastUpdated, @imageUrl, @originalDoc); SELECT * FROM {FeedTable} WHERE url=@url", dbc)
{ {
Parameters = Parameters =
{ {
@ -154,8 +154,8 @@ namespace SharpRss
new SqliteParameter("description", feedModel.Description ?? string.Empty), new SqliteParameter("description", feedModel.Description ?? string.Empty),
new SqliteParameter("language", feedModel.Language ?? string.Empty), new SqliteParameter("language", feedModel.Language ?? string.Empty),
new SqliteParameter("copyright", feedModel.Copyright ?? string.Empty), new SqliteParameter("copyright", feedModel.Copyright ?? string.Empty),
new SqliteParameter("dateAdded", feedModel.DateAdded?.ToUnixTimeMilliseconds()), new SqliteParameter("dateAdded", feedModel.DateAdded?.ToUnixTimeMilliseconds() ?? 0),
new SqliteParameter("lastUpdated", feedModel.LastUpdated?.ToUnixTimeMilliseconds()), new SqliteParameter("lastUpdated", feedModel.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
new SqliteParameter("imageUrl", feedModel.ImageUrl ?? string.Empty), new SqliteParameter("imageUrl", feedModel.ImageUrl ?? string.Empty),
new SqliteParameter("originalDoc", feedModel.OriginalDocument ?? string.Empty) new SqliteParameter("originalDoc", feedModel.OriginalDocument ?? string.Empty)
} }

View File

@ -49,9 +49,9 @@ namespace SharpRss.Services
// Add feed // Add feed
FeedModel? dbFeed = await DbAccess.SetFeedAsync(fModel); FeedModel? dbFeed = await DbAccess.SetFeedAsync(fModel);
// Update/fetch items // Update/fetch items
await DbAccess.FetchFeedItemsAsync(new string[] { fModel.Url }); //await DbAccess.FetchFeedItemsAsync(new string[] { fModel.Url });
} }
return false; return true;
} }
private static FeedModel FromResource(ISyndicationResource resource) private static FeedModel FromResource(ISyndicationResource resource)
{ {
@ -60,6 +60,13 @@ namespace SharpRss.Services
{ {
case SyndicationContentFormat.Rss: case SyndicationContentFormat.Rss:
RssFeed rssFeed = (RssFeed)resource; RssFeed rssFeed = (RssFeed)resource;
model.FeedType = rssFeed.Format.ToString();
model.Title = rssFeed.Channel.Title;
model.Description = rssFeed.Channel.Description;
model.Copyright = rssFeed.Channel.Copyright;
model.Url = rssFeed.Channel.SelfLink.ToString();
model.ImageUrl = rssFeed.Channel.Image?.Url.ToString();
model.Language = rssFeed.Channel.Language?.ToString();
break; break;
case SyndicationContentFormat.Atom: case SyndicationContentFormat.Atom:
AtomFeed atomFeed = (AtomFeed)resource; AtomFeed atomFeed = (AtomFeed)resource;
@ -158,8 +165,8 @@ namespace SharpRss.Services
throw; throw;
}*/ }*/
/*var groups = await GetGroupsAsync(); /*var groups = await GetGroupsAsync();
CategoryModel testGroup = groups.Single(x => x.Name == "News");*/ CategoryModel testGroup = groups.Single(x => x.Name == "News");
await AddSubscriptionAsync("https://www.nu.nl/rss/Algemeen"); await AddSubscriptionAsync("https://www.nu.nl/rss/Algemeen", testGroup);*/
/*await AddFeedsAsync(new[] /*await AddFeedsAsync(new[]
{ {
"https://www.nu.nl/rss/Algemeen", "https://www.nu.nl/rss/Algemeen",

Binary file not shown.