forked from dysosmus/miniflux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cronjob.php
35 lines (26 loc) · 1.07 KB
/
cronjob.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require __DIR__.'/common.php';
if (php_sapi_name() === 'cli') {
$options = getopt('', array(
'limit::',
'call-interval::',
'update-interval::',
'database::',
));
}
else {
$options = $_GET;
}
if (! empty($options['database'])) {
Model\Database\select($options['database']);
}
$limit = ! empty($options['limit']) && ctype_digit($options['limit']) ? (int) $options['limit'] : Model\Feed\LIMIT_ALL;
$update_interval = ! empty($options['update-interval']) && ctype_digit($options['update-interval']) ? (int) $options['update-interval'] : null;
$call_interval = ! empty($options['call-interval']) && ctype_digit($options['call-interval']) ? (int) $options['call-interval'] : null;
if ($update_interval !== null && $call_interval !== null && $limit === Model\Feed\LIMIT_ALL && $update_interval >= $call_interval) {
$feeds_count = PicoDb\Database::get('db')->table('feeds')->count();
$limit = ceil($feeds_count / ($update_interval / $call_interval));
}
Model\Feed\refresh_all($limit);
Model\Item\autoflush();
Model\Config\write_debug();