break;
}
+ str = str.replace(/<[^>]+>/g, '');
+
return str;
}
const feedsToQuery = completeFeedList.filter(feed => {
// only update every 5 minutes
- //return Date.now() > (feed.updated_at + 1000 * 60 * 5);
- return true;
+ return Date.now() > (feed.updated_at + (1000 * 60 * 5));
});
console.log(`Querying ${feedsToQuery.length} feeds`);
+ const now = Date.now();
for(let feed of feedsToQuery) {
console.log(`Querying ${feed.title}(${feed.url})`);
const items: FeedEntrySchema<any>[] = data.items.map(item => {
return {
- id: item.guid,
+ id: item.guid || item.id,
title: item.title,
link: item.link,
feed_id: feed.id,
pub_date: Math.floor(new Date(item.pubDate).getTime()/1000),
- author: item.creator,
- created_at: Math.floor(Date.now()/1000),
- updated_at: Math.floor(Date.now()/1000),
+ author: item.creator || item.author,
+ created_at: Math.floor(now/1000),
+ updated_at: Math.floor(now/1000),
meta: {
comment_link: item.comments,
snippet: contentExtractor(feed, item)
}
await db('feeds').update({
- updated_at: new Date()
+ updated_at: Math.floor(Date.now()/1000)
}).where({
id: feed.id
});
title: req.body.title,
favicon: req.body.favicon,
created_at: now,
- updated_at: now
+ updated_at: 0
};
const rows = await db('feeds').insert(feed).onConflict().ignore().returning('*');