feat(collect): add --fromDate lower bound for zomb-eh re-queue branch
The zomb-eh periodic re-queue branch in GetPosts had no lower bound on the post's original PostDate -- it re-queued every already-collected zomb-eh post past the 3-day cooldown, regardless of age. Add --fromDate <datetime> to bound that branch by PostDate >= the given date. It stacks with the existing cooldown clause rather than replacing it, so it applies the same way whether or not --force also drops the cooldown.
This commit is contained in:
@@ -855,13 +855,14 @@ namespace URLNotesGrabberCORE
|
||||
#region Gets
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <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="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, 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, string? DBPath = null)
|
||||
{
|
||||
DBPath ??= GetDefaultDbPath();
|
||||
using SQLiteConnection connection = new SQLiteConnection("Data Source=" + DBPath);
|
||||
@@ -903,6 +904,15 @@ namespace URLNotesGrabberCORE
|
||||
? string.Empty
|
||||
: " AND NotesGatheredDateTime < unixepoch('now', 'localtime', '-3 days')" + Environment.NewLine;
|
||||
|
||||
// --fromDate bounds the *original post's* PostDate, not the re-collect cooldown --
|
||||
// it stacks with refreshCooldownClause instead of replacing it, so it applies the
|
||||
// same way whether or not --force also dropped the cooldown. A NULL PostDate never
|
||||
// satisfies ">=" and is excluded, same as an unfiltered run would still include it
|
||||
// (there's nothing to compare here, so this only narrows, never widens, the result).
|
||||
string fromDateClause = fromDate.HasValue
|
||||
? " AND PostDate >= @fromDate" + Environment.NewLine
|
||||
: string.Empty;
|
||||
|
||||
string refreshBranch =
|
||||
"" + Environment.NewLine +
|
||||
" UNION " + Environment.NewLine +
|
||||
@@ -917,7 +927,8 @@ namespace URLNotesGrabberCORE
|
||||
" FROM PostsWithCount" + Environment.NewLine +
|
||||
" WHERE BlogName = 'zomb-eh'" + Environment.NewLine +
|
||||
" AND NotFound = 0" + Environment.NewLine +
|
||||
refreshCooldownClause;
|
||||
refreshCooldownClause +
|
||||
fromDateClause;
|
||||
|
||||
sql = "WITH PostsWithCount AS" + Environment.NewLine +
|
||||
"(" + Environment.NewLine +
|
||||
@@ -1001,6 +1012,11 @@ namespace URLNotesGrabberCORE
|
||||
if (filterByBlog)
|
||||
command.Parameters.AddWithValue("@blogName", blogName);
|
||||
|
||||
// Only ever referenced by the zomb-eh refresh branch, which only exists when
|
||||
// withoutNotesOnly is true -- harmless to bind unconditionally otherwise.
|
||||
if (fromDate.HasValue)
|
||||
command.Parameters.AddWithValue("@fromDate", fromDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
|
||||
Reference in New Issue
Block a user