mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +01:00
Need db reworking for usage new syndication system
This commit is contained in:
parent
ce90818e3d
commit
924e174240
|
@ -4,6 +4,7 @@ using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Argotic.Syndication;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
@ -160,8 +161,36 @@ namespace SharpRss
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
|
await FetchFeedItemsAsync(feedModels.Select(x => x.Url).ToArray());
|
||||||
return resultModel;
|
return resultModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task FetchFeedItemsAsync(string[]? feedUrls = null)
|
||||||
|
{
|
||||||
|
await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
|
||||||
|
dbc.Open();
|
||||||
|
HashSet<FeedModel> dbFeeds = new HashSet<FeedModel>();
|
||||||
|
string query = $"SELECT * FROM {FeedTable}";
|
||||||
|
if (feedUrls != null)
|
||||||
|
{
|
||||||
|
List<string>? feedUrlsFormatted = feedUrls.Select(s => $"'{s}'").ToList();
|
||||||
|
query = $"SELECT * FROM {FeedTable} WHERE url IN(({string.Join(", ", feedUrlsFormatted)}))";
|
||||||
|
}
|
||||||
|
await using SqliteCommand fetchCmd = new SqliteCommand(query, dbc);
|
||||||
|
await using SqliteDataReader reader = await fetchCmd.ExecuteReaderAsync();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
dbFeeds.Add(await ReaderToFeedModel(reader));
|
||||||
|
}
|
||||||
|
HashSet<FeedItemModel> feedItems = new HashSet<FeedItemModel>();
|
||||||
|
foreach (var dbFeed in dbFeeds)
|
||||||
|
{
|
||||||
|
GenericSyndicationFeed syndication = new GenericSyndicationFeed();
|
||||||
|
syndication.Load(dbFeed.OriginalDocument);
|
||||||
|
}
|
||||||
|
//TODO: Rewrite some stuff...
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<bool> RemoveFeedAsync(FeedModel feedModel)
|
public static async Task<bool> RemoveFeedAsync(FeedModel feedModel)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user