feat(collect): add --toDate upper bound for zomb-eh re-queue branch
Mirrors --fromDate: bounds the zomb-eh periodic re-queue branch by PostDate <= the given date. Stacks alongside --fromDate and the cooldown clause rather than replacing either, so --fromDate/--toDate and --force can all be combined, and each applies with or without --force. Named --toDate rather than --end to pair with --fromDate -- --start already exists as an unrelated flag (resume folder traversal at a blog name).
This commit is contained in:
@@ -860,9 +860,10 @@ namespace URLNotesGrabberCORE
|
||||
/// <param name="withoutNotesOnly"></param>
|
||||
/// <param name="ignoreRefreshCooldown">Drops the age gate on the periodic re-queue branch (--force).</param>
|
||||
/// <param name="fromDate">Lower bound on the *original post's* PostDate for the periodic re-queue branch (--fromDate). Independent of ignoreRefreshCooldown -- applies whether or not --force is also given.</param>
|
||||
/// <param name="toDate">Upper bound on the *original post's* PostDate for the periodic re-queue branch (--toDate). Same independence from ignoreRefreshCooldown as fromDate.</param>
|
||||
/// <param name="DBPath"></param>
|
||||
/// <returns>blogName, postID, lastNoteTimestamp, notesGatheredTimestamp</returns>
|
||||
public static List<Tuple<string, long, long, long>> GetPosts(bool withoutNotesOnly = false, DateTime? beforeDate = null, string? blogName = null, bool ignoreRefreshCooldown = false, DateTime? fromDate = null, string? DBPath = null)
|
||||
public static List<Tuple<string, long, long, long>> GetPosts(bool withoutNotesOnly = false, DateTime? beforeDate = null, string? blogName = null, bool ignoreRefreshCooldown = false, DateTime? fromDate = null, DateTime? toDate = null, string? DBPath = null)
|
||||
{
|
||||
DBPath ??= GetDefaultDbPath();
|
||||
using SQLiteConnection connection = new SQLiteConnection("Data Source=" + DBPath);
|
||||
@@ -913,6 +914,13 @@ namespace URLNotesGrabberCORE
|
||||
? " AND PostDate >= @fromDate" + Environment.NewLine
|
||||
: string.Empty;
|
||||
|
||||
// --toDate is the same deal, mirrored: stacks alongside fromDateClause/
|
||||
// refreshCooldownClause rather than replacing either, so --fromDate and --toDate
|
||||
// can be given together (or alone) and both hold with or without --force.
|
||||
string toDateClause = toDate.HasValue
|
||||
? " AND PostDate <= @toDate" + Environment.NewLine
|
||||
: string.Empty;
|
||||
|
||||
string refreshBranch =
|
||||
"" + Environment.NewLine +
|
||||
" UNION " + Environment.NewLine +
|
||||
@@ -928,7 +936,8 @@ namespace URLNotesGrabberCORE
|
||||
" WHERE BlogName = 'zomb-eh'" + Environment.NewLine +
|
||||
" AND NotFound = 0" + Environment.NewLine +
|
||||
refreshCooldownClause +
|
||||
fromDateClause;
|
||||
fromDateClause +
|
||||
toDateClause;
|
||||
|
||||
sql = "WITH PostsWithCount AS" + Environment.NewLine +
|
||||
"(" + Environment.NewLine +
|
||||
@@ -1016,6 +1025,8 @@ namespace URLNotesGrabberCORE
|
||||
// withoutNotesOnly is true -- harmless to bind unconditionally otherwise.
|
||||
if (fromDate.HasValue)
|
||||
command.Parameters.AddWithValue("@fromDate", fromDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
if (toDate.HasValue)
|
||||
command.Parameters.AddWithValue("@toDate", toDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user