Fixed duplicate insertions into the filtered database.
This commit is contained in:
Binary file not shown.
@@ -25,6 +25,7 @@ public class DbHandler
|
||||
private const string ReadUnfilteredIdsStatement = "SELECT Id FROM Unfiltered WHERE Id != 0 ORDER BY Id DESC LIMIT 1;";
|
||||
private const string ReadFilteredStatement = "SELECT Title2, Url2 FROM Filtered WHERE (Url2 NOT NULL AND Url2 != '') AND (Title2 NOT NULL AND Title2 != '') ORDER BY Url2 DESC;";
|
||||
private const string ReadFilteredIdsStatement = "SELECT Id FROM Filtered WHERE Id != 0 ORDER BY Id DESC LIMIT 1;";
|
||||
private const string ReadFilteredIpStatement = "SELECT Ip FROM Filtered WHERE Ip == @ip ORDER BY Ip DESC LIMIT 1;";
|
||||
private const string ReadDiscardedSeqIdsStatement = "SELECT seq FROM sqlite_sequence;";
|
||||
private const string ReadAndDeleteResumeStatement = "SELECT * FROM Resume WHERE ThreadNumber == @threadNumber; DELETE FROM RESUME WHERE ThreadNumber == @threadNumber;";
|
||||
|
||||
@@ -365,7 +366,27 @@ public class DbHandler
|
||||
|
||||
public bool GetFilteredIp(string ip)
|
||||
{
|
||||
return true;
|
||||
using SqliteConnection connection = new(_filteredConnectionString);
|
||||
connection.Open();
|
||||
|
||||
using SqliteCommand command = new(ReadFilteredIpStatement, connection);
|
||||
command.Parameters.AddWithValue("@ip", ip);
|
||||
|
||||
using SqliteDataReader reader = command.ExecuteReader();
|
||||
|
||||
if (!reader.HasRows)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string ipAddress = "";
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
ipAddress = reader.GetString(0);
|
||||
}
|
||||
|
||||
return ipAddress == ip;
|
||||
}
|
||||
|
||||
public List<SearchResult?> GetSearchResults()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user