Documents and Documentation (beta 1) (#23)

- Change to SQLite document store
- Complete documentation on usage of Feed Reader Central
- Update INSTALLING.md for new installation procedures

Reviewed-on: #23
This commit was merged in pull request #23.
This commit is contained in:
2024-06-12 02:07:35 +00:00
parent 819979f2b2
commit 0c87392910
43 changed files with 1652 additions and 1142 deletions

View File

@@ -1,5 +1,7 @@
<?php
use JetBrains\PhpStorm\NoReturn;
<?php declare(strict_types=1);
use BitBadger\PDODocument\{DocumentException, Find};
use FeedReaderCentral\{Feed, Table, User};
require __DIR__ . '/../cli-start.php';
@@ -20,34 +22,32 @@ switch ($argv[1]) {
/**
* Display the options for this utility and exit
*/
#[NoReturn]
function display_help(): void {
function display_help(): never
{
printfn('Options:');
printfn(' - all');
printfn(' Refreshes all feeds');
exit(0);
}
function refresh_all(): void {
$db = Data::getConnection();
function refresh_all(): void
{
try {
$feeds = Feed::retrieveAll($db);
if (array_key_exists('error', $feeds)) {
printfn('SQLite error: %s', $feeds['error']);
return;
}
array_walk($feeds, function ($feed) use ($db) {
$result = Feed::refreshFeed($feed['id'], $feed['url'], $db);
$users = [];
iterator_apply(Feed::retrieveAll()->items(), 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);
if (array_key_exists('error', $result)) {
printfn('ERR (%s) %s', $feed['email'], $feed['url']);
printfn('ERR (%s) %s', $users[$userKey]->email, $feed->url);
printfn(' %s', $result['error']);
} else {
printfn('OK (%s) %s', $feed['email'], $feed['url']);
printfn('OK (%s) %s', $users[$userKey]->email, $feed->url);
}
});
printfn(PHP_EOL . 'All feeds refreshed');
} finally {
$db->close();
} catch (DocumentException $ex) {
printfn("ERR $ex");
return;
}
}