mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +01:00
Fixed queries. TODO: Test dapper version!
This commit is contained in:
parent
2a4d20682e
commit
a17b2a7ebf
|
@ -73,7 +73,32 @@ namespace SharpRss
|
||||||
{
|
{
|
||||||
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 feed (url, title, category_id, feed_type, feed_version, description, language, copyright, publication_date, last_updated, categories, image_url) VALUES (@Url, @Title, @CategoryId, @FeedType, @FeedVersion, @Description, @Language, @Copyright, @PublicationDate, @LastUpdated, @Categories, @ImageUrl)", dbc)
|
await using SqliteCommand cmd = new SqliteCommand(@"INSERT OR REPLACE INTO feed
|
||||||
|
(url,
|
||||||
|
title,
|
||||||
|
category_id,
|
||||||
|
feed_type,
|
||||||
|
feed_version,
|
||||||
|
description,
|
||||||
|
language,
|
||||||
|
copyright,
|
||||||
|
publication_date,
|
||||||
|
last_updated,
|
||||||
|
categories,
|
||||||
|
image_url)
|
||||||
|
VALUES (
|
||||||
|
@Url,
|
||||||
|
@Title,
|
||||||
|
@CategoryId,
|
||||||
|
@FeedType,
|
||||||
|
@FeedVersion,
|
||||||
|
@Description,
|
||||||
|
@Language,
|
||||||
|
@Copyright,
|
||||||
|
@PublicationDate,
|
||||||
|
@LastUpdated,
|
||||||
|
@Categories,
|
||||||
|
@ImageUrl)", dbc)
|
||||||
{
|
{
|
||||||
Parameters =
|
Parameters =
|
||||||
{
|
{
|
||||||
|
@ -81,6 +106,7 @@ namespace SharpRss
|
||||||
new SqliteParameter("Title", feed.Title ?? string.Empty),
|
new SqliteParameter("Title", feed.Title ?? string.Empty),
|
||||||
new SqliteParameter("CategoryId", feed.CategoryId ?? string.Empty),
|
new SqliteParameter("CategoryId", feed.CategoryId ?? string.Empty),
|
||||||
new SqliteParameter("FeedType", feed.FeedType ?? string.Empty),
|
new SqliteParameter("FeedType", feed.FeedType ?? string.Empty),
|
||||||
|
new SqliteParameter("FeedVersion", feed.FeedVersion ?? string.Empty),
|
||||||
new SqliteParameter("Description", feed.Description ?? string.Empty),
|
new SqliteParameter("Description", feed.Description ?? string.Empty),
|
||||||
new SqliteParameter("Language", feed.Language ?? string.Empty),
|
new SqliteParameter("Language", feed.Language ?? string.Empty),
|
||||||
new SqliteParameter("Copyright", feed.Copyright ?? string.Empty),
|
new SqliteParameter("Copyright", feed.Copyright ?? string.Empty),
|
||||||
|
@ -98,6 +124,7 @@ namespace SharpRss
|
||||||
Title = feed.Title ?? string.Empty,
|
Title = feed.Title ?? string.Empty,
|
||||||
CategoryId = feed.CategoryId ?? string.Empty,
|
CategoryId = feed.CategoryId ?? string.Empty,
|
||||||
FeedType = feed.FeedType ?? string.Empty,
|
FeedType = feed.FeedType ?? string.Empty,
|
||||||
|
FeedVersion = feed.FeedVersion ?? string.Empty,
|
||||||
Description = feed.Description ?? string.Empty,
|
Description = feed.Description ?? string.Empty,
|
||||||
Language = feed.Language ?? string.Empty,
|
Language = feed.Language ?? string.Empty,
|
||||||
Copyright = feed.Copyright ?? string.Empty,
|
Copyright = feed.Copyright ?? string.Empty,
|
||||||
|
@ -105,8 +132,8 @@ namespace SharpRss
|
||||||
LastUpdated = feed.LastUpdated?.ToUnixTimeMilliseconds() ?? 0,
|
LastUpdated = feed.LastUpdated?.ToUnixTimeMilliseconds() ?? 0,
|
||||||
Categories = feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty,
|
Categories = feed.Categories.Any() ? string.Join(',', feed.Categories) : string.Empty,
|
||||||
ImageUrl = feed.ImageUrl ?? string.Empty
|
ImageUrl = feed.ImageUrl ?? string.Empty
|
||||||
});*/
|
});
|
||||||
/*if (affected == 0)
|
if (affected == 0)
|
||||||
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);*/
|
Log.Warning("Failed to add feed: {FeedUrl}", feed.OriginalUrl);*/
|
||||||
}
|
}
|
||||||
public static async Task<HashSet<FeedModel>> GetFeedsAsync(string[]? categoryIds = null)
|
public static async Task<HashSet<FeedModel>> GetFeedsAsync(string[]? categoryIds = null)
|
||||||
|
@ -145,13 +172,15 @@ namespace SharpRss
|
||||||
await using SqliteTransaction dbTransaction = dbc.BeginTransaction();
|
await using SqliteTransaction dbTransaction = dbc.BeginTransaction();
|
||||||
foreach (FeedItemModel item in items)
|
foreach (FeedItemModel item in items)
|
||||||
{
|
{
|
||||||
await using SqliteCommand cmd = new SqliteCommand("INSERT OR REPLACE INTO feed (url, title, category_id, feed_type, feed_version, description, language, copyright, publication_date, last_updated, categories, image_url) VALUES (@Url, @Title, @CategoryId, @FeedType, @FeedVersion, @Description, @language, @Copyright, @PublicationDate, @LastUpdated, @Categories, @ImageUrl)", dbc, dbTransaction)
|
await using SqliteCommand cmd = new SqliteCommand(@"INSERT OR REPLACE INTO feed_item (id, feed_url, read, title, description, link, last_updated, publishing_date, authors, categories, content)
|
||||||
|
VALUES (@Id, @FeedUrl, @Read, @Title, @Description, @Link, @LastUpdated, @PublishingDate, @Authors, @Categories, @Content)", dbc, dbTransaction)
|
||||||
{
|
{
|
||||||
Parameters =
|
Parameters =
|
||||||
{
|
{
|
||||||
new SqliteParameter("Id", item.Id ?? string.Empty),
|
new SqliteParameter("Id", item.Id ?? string.Empty),
|
||||||
new SqliteParameter("FeedUrl", item.FeedUrl ?? string.Empty),
|
new SqliteParameter("FeedUrl", item.FeedUrl ?? string.Empty),
|
||||||
new SqliteParameter("Read", item.Read.ToString()),
|
new SqliteParameter("Read", item.Read.ToString()),
|
||||||
|
new SqliteParameter("Title", item.Title),
|
||||||
new SqliteParameter("Description", item.Description ?? string.Empty),
|
new SqliteParameter("Description", item.Description ?? string.Empty),
|
||||||
new SqliteParameter("Link", item.Link ?? string.Empty),
|
new SqliteParameter("Link", item.Link ?? string.Empty),
|
||||||
new SqliteParameter("LastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
|
new SqliteParameter("LastUpdated", item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0),
|
||||||
|
@ -162,13 +191,15 @@ namespace SharpRss
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int exec = await cmd.ExecuteNonQueryAsync();
|
int exec = await cmd.ExecuteNonQueryAsync();
|
||||||
/*int affected = await dbc.ExecuteAsync("INSERT OR REPLACE INTO feed_item (id, feed_url, read, title, description, link, last_updated, publishing_date, authors, categories, content) VALUES (@Id, @FeedUrl, @Read, @Title, Description, @Link, @LastUpdated, @PublishingDate, @Authors, @Categories, @Content)",
|
/*int affected = await dbc.ExecuteAsync(@"INSERT OR REPLACE INTO feed_item (id, feed_url, read, title, description, link, last_updated, publishing_date, authors, categories, content)
|
||||||
|
VALUES (@Id, @FeedUrl, @Read, @Title, @Description, @Link, @LastUpdated, @PublishingDate, @Authors, @Categories, @Content)",
|
||||||
transaction: dbTransaction,
|
transaction: dbTransaction,
|
||||||
param: new
|
param: new
|
||||||
{
|
{
|
||||||
Id = item.Id ?? string.Empty,
|
Id = item.Id ?? string.Empty,
|
||||||
FeedUrl = item.FeedUrl ?? string.Empty,
|
FeedUrl = item.FeedUrl ?? string.Empty,
|
||||||
Read = item.Read.ToString(),
|
Read = item.Read.ToString(),
|
||||||
|
Title = item.Title ?? string.Empty,
|
||||||
Description = item.Description ?? string.Empty,
|
Description = item.Description ?? string.Empty,
|
||||||
Link = item.Link ?? string.Empty,
|
Link = item.Link ?? string.Empty,
|
||||||
LastUpdated = item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0,
|
LastUpdated = item.LastUpdated?.ToUnixTimeMilliseconds() ?? 0,
|
||||||
|
@ -176,8 +207,8 @@ namespace SharpRss
|
||||||
Authors = item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty,
|
Authors = item.Authors.Any() ? string.Join(',', item.Authors) : string.Empty,
|
||||||
Categories = item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty,
|
Categories = item.Categories.Any() ? string.Join(',', item.Categories) : string.Empty,
|
||||||
Content = item.Content ?? string.Empty
|
Content = item.Content ?? string.Empty
|
||||||
});*/
|
});
|
||||||
totalAffected += exec;
|
totalAffected += affected;*/
|
||||||
}
|
}
|
||||||
dbTransaction.Commit();
|
dbTransaction.Commit();
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user