Split out feed parsing from document
WIP - still moving things around...
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use BitBadger\Documents\DocumentException;
|
||||
use BitBadger\Documents\SQLite\Find;
|
||||
use FeedReaderCentral\Data;
|
||||
use FeedReaderCentral\Domain\Feed as FeedDocument;
|
||||
use FeedReaderCentral\Domain\Table;
|
||||
use FeedReaderCentral\Domain\User;
|
||||
use FeedReaderCentral\Feed;
|
||||
@@ -36,12 +37,11 @@ function display_help(): never
|
||||
|
||||
function refresh_all(): void
|
||||
{
|
||||
$db = Data::getConnection();
|
||||
$users = [];
|
||||
$db = Data::getConnection();
|
||||
|
||||
try {
|
||||
$feeds = Feed::retrieveAll();
|
||||
foreach ($feeds->items() as /** @var Feed $feed */ $feed) {
|
||||
$users = [];
|
||||
iterator_apply(Feed::retrieveAll()->items(), function (FeedDocument $feed) use ($db, $users) {
|
||||
$result = Feed::refreshFeed($feed->id, $feed->url, $db);
|
||||
$userKey = "$feed->user_id";
|
||||
if (!key_exists($userKey, $users)) $users[$userKey] = Find::byId(Table::USER, $feed->user_id, User::class);
|
||||
@@ -51,7 +51,7 @@ function refresh_all(): void
|
||||
} else {
|
||||
printfn('OK (%s) %s', $users[$userKey]->email, $feed->url);
|
||||
}
|
||||
}
|
||||
});
|
||||
printfn(PHP_EOL . 'All feeds refreshed');
|
||||
} catch (DocumentException $ex) {
|
||||
printfn("ERR $ex");
|
||||
|
||||
Reference in New Issue
Block a user