7 Commits
2 changed files with 22 additions and 25 deletions

No files matched your search

+17 -22
View File
@@ -1364,32 +1364,27 @@ namespace URLNotesGrabberCORE
WHERE BlogName IN ({placeholders}) WHERE BlogName IN ({placeholders})
AND IsActive = 1"; AND IsActive = 1";
} }
else if (ignoreCooldown)
{
// All active blogs, ignore cooldown
sql = @"SELECT BlogName,
COALESCE(LikesPulled, 0),
COALESCE(LikesCursor, 0),
COALESCE(LikesNewestTimestamp, 0)
FROM Blogs
WHERE IsActive = 1
ORDER BY COALESCE(LikesLastRefreshed, 0), BlogName;";
}
else else
{ {
// Backfill-pending OR refresh-due (past cooldown window) // Only blogs that have left a note; least recently refreshed first, then earliest first note
sql = @"SELECT BlogName, string dueFilter = ignoreCooldown ? string.Empty : @"
COALESCE(LikesPulled, 0),
COALESCE(LikesCursor, 0),
COALESCE(LikesNewestTimestamp, 0)
FROM Blogs
WHERE IsActive = 1
AND ( AND (
COALESCE(LikesPulled, 0) = 0 COALESCE(B.LikesPulled, 0) = 0
OR COALESCE(LikesLastRefreshed, 0) OR COALESCE(B.LikesLastRefreshed, 0)
< (CAST(strftime('%s','now') AS INTEGER) - (@cooldownDays * 86400)) < (CAST(strftime('%s','now') AS INTEGER) - (@cooldownDays * 86400))
) )";
ORDER BY COALESCE(LikesLastRefreshed, 0), BlogName;"; sql = @"SELECT B.BlogName,
COALESCE(B.LikesPulled, 0),
COALESCE(B.LikesCursor, 0),
COALESCE(B.LikesNewestTimestamp, 0)
FROM Blogs B
INNER JOIN (SELECT N.NoteBlogId, MIN(N.TimeStamp) AS FirstNoteTs
FROM Notes N" + WhereIsActive("Notes", "N", DBPath) + @"
GROUP BY N.NoteBlogId) F ON F.NoteBlogId = B.BlogId
WHERE B.IsActive = 1" + dueFilter + @"
ORDER BY COALESCE(B.LikesLastRefreshed, 0),
F.FirstNoteTs,
B.BlogName;";
} }
using (SQLiteCommand command = new SQLiteCommand(sql, connection)) using (SQLiteCommand command = new SQLiteCommand(sql, connection))
+5 -3
View File
@@ -170,9 +170,10 @@ namespace URLNotesGrabberCORE
} }
string? containsListSetting = settings.GetValue<string>("ContainsList"); string? containsListSetting = settings.GetValue<string>("ContainsList");
if (string.IsNullOrEmpty(containsListSetting)) List<string> contains = (containsListSetting ?? string.Empty)
.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToList();
if (contains.Count == 0)
throw new InvalidOperationException("ContainsList is not configured in appsettings.json"); throw new InvalidOperationException("ContainsList is not configured in appsettings.json");
List<string> contains = containsListSetting.Split(',').ToList();
bool logTraversalRecordImports = settings.GetValue("LogTraversalRecordImports", false); bool logTraversalRecordImports = settings.GetValue("LogTraversalRecordImports", false);
if (args.Length == 0) //Traverse folder structure to add posts and thus blogs to DB if (args.Length == 0) //Traverse folder structure to add posts and thus blogs to DB
@@ -971,7 +972,8 @@ namespace URLNotesGrabberCORE
if (isRefresh) cursor = 0; if (isRefresh) cursor = 0;
string mode = isRefresh ? "REFRESH" : "BACKFILL"; string mode = isRefresh ? "REFRESH" : "BACKFILL";
Console.WriteLine($"[{remaining} remaining] Processing likes for blog: {blogName} | Mode: {mode} | Cursor: {cursor} | HighWaterMark: {storedNewestTs}"); int pct = blogsToProcess.Count > 0 ? (((i + 1) * 100) / blogsToProcess.Count) : 0;
Console.WriteLine($"[{i + 1}/{blogsToProcess.Count} ({pct}%) | {remaining} remaining] Processing likes for blog: {blogName} | Mode: {mode} | Cursor: {cursor} | HighWaterMark: {storedNewestTs}");
bool hasMoreLikes = true; bool hasMoreLikes = true;
bool isFirstPage = true; bool isFirstPage = true;