Completed result/option migration
- Change casing on exposed constants - Add file-level phpdoc
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Feed Refresh Utility
|
||||
*
|
||||
* This will refresh all known feeds in the database; it is suitable for executing via cron or as a scheduled task
|
||||
*
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use BitBadger\PDODocument\{DocumentException, Find};
|
||||
use FeedReaderCentral\{Feed, Table, User};
|
||||
@@ -34,11 +44,11 @@ function refresh_all(): void
|
||||
{
|
||||
try {
|
||||
$users = [];
|
||||
foreach (Feed::retrieveAll()->items() as /** @var Feed $feed */ $feed) {
|
||||
Feed::retrieveAll()->iter(function (Feed $feed) use (&$users) {
|
||||
$result = Feed::refreshFeed($feed->id, $feed->url);
|
||||
$userKey = "$feed->user_id";
|
||||
if (!key_exists($userKey, $users)) {
|
||||
$users[$userKey] = Find::byId(Table::USER, $feed->user_id, User::class)
|
||||
$users[$userKey] = Find::byId(Table::User, $feed->user_id, User::class)
|
||||
->getOrElse(new User(email: 'user-not-found'));
|
||||
}
|
||||
if ($result->error()->isDefined()) {
|
||||
@@ -47,7 +57,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