import { extendFeeds } from "https://esm.town/v/iakovos/extendFeeds";
import { feedLogs } from "https://esm.town/v/iakovos/feedLogs";
import { getTopScoredArticles } from "https://esm.town/v/iakovos/getTopScoredArticles";
import { interests } from "https://esm.town/v/iakovos/interests";
import { pollRSSFeeds } from "https://esm.town/v/iakovos/pollRSSFeeds";
import { renderFeedsForEmail } from "https://esm.town/v/iakovos/renderFeedsForEmail";
import { scoreAndCombineArticles } from "https://esm.town/v/iakovos/scoreAndCombineArticles";
import { email } from "https://esm.town/v/std/email?v=9";
import { set } from "https://esm.town/v/std/set?v=11";
export const pollAndEmailArticles = async () => {
const feeds = await pollRSSFeeds();
const hasFeeds = feeds?.length > 0;
if (hasFeeds) {
const extendedFeeds = extendFeeds(feeds);
const blogs = extendedFeeds.filter((feed) => feed.type === "blog");
const articles = extendedFeeds.filter((feed) => feed.type !== "blog");
const scoredArticles = await scoreAndCombineArticles(
articles,
interests,
);
const topArticles = getTopScoredArticles(scoredArticles, 35) ?? [];
const allItems = [...blogs, ...topArticles];
return allItems;
}
};