feat(likes): accept multiple blog names with --likes

Change --likes from accepting a single blog name to accepting a list.
Passes all non-flag args after --likes as blog names. Database stores
bare blog names, so users pass just the name without .tumblr.com.

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
jimandClaude committed 2026-10-19 13:41:05 -05:00
1 parent ca99586176
commit 7557c9a168
2 files changed
+22 -16

No files matched your search

+11 -11
View File
@@ -1341,7 +1341,7 @@ namespace URLNotesGrabberCORE
return count;
}
public static List<Tuple<string, int, long, long>> GetBlogsForLikes(string specificBlog = null, int cooldownDays = 7, bool ignoreCooldown = false, string? DBPath = null)
public static List<Tuple<string, int, long, long>> GetBlogsForLikes(List<string> specificBlogs = null, int cooldownDays = 7, bool ignoreCooldown = false, string? DBPath = null)
{
DBPath ??= GetDefaultDbPath();
using SQLiteConnection connection = new SQLiteConnection("Data Source=" + DBPath);
@@ -1352,19 +1352,16 @@ namespace URLNotesGrabberCORE
connection.Open();
string sql;
// The two Notes branches below join on Blogs.BlogId, which is NULL for the 168k
// registry rows that have never appeared in a note. The inner join drops them,
// which is correct here -- both branches already require a note to exist -- but
// it is the wrong shape for anything that lists the registry.
if (!string.IsNullOrEmpty(specificBlog))
if (specificBlogs != null && specificBlogs.Count > 0)
{
// Specific blog: always process, bypass cooldown
sql = @"SELECT BlogName,
// Specific blogs: always process, bypass cooldown
var placeholders = string.Join(", ", specificBlogs.Select((_, i) => $"@blog{i}"));
sql = $@"SELECT BlogName,
COALESCE(LikesPulled, 0),
COALESCE(LikesCursor, 0),
COALESCE(LikesNewestTimestamp, 0)
FROM Blogs
WHERE BlogName = @blog
WHERE BlogName IN ({placeholders})
AND IsActive = 1";
}
else if (ignoreCooldown)
@@ -1405,8 +1402,11 @@ namespace URLNotesGrabberCORE
using (SQLiteCommand command = new SQLiteCommand(sql, connection))
{
if (!string.IsNullOrEmpty(specificBlog))
command.Parameters.AddWithValue("@blog", specificBlog);
if (specificBlogs != null && specificBlogs.Count > 0)
{
for (int i = 0; i < specificBlogs.Count; i++)
command.Parameters.AddWithValue($"@blog{i}", specificBlogs[i]);
}
else if (!ignoreCooldown)
command.Parameters.AddWithValue("@cooldownDays", cooldownDays);