Completed
Pull Request — development (#622)
by Thomas
06:17
created

SearchIndex::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/***************************************************************************
3
 * for license information see LICENSE.md
4
 *
5
 * updates full text search index
6
 ***************************************************************************/
7
8
include __DIR__ . '/../../../lib2/search/ftsearch.inc.php';
9
10
checkJob(new SearchIndex());
11
12
class SearchIndex
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
{
14
    public $name = 'search_index';
15
    public $interval = 0;
16
17
    public function run()
18
    {
19
        // ftsearch_refresh() will roughly process 5-50 search_index_times entries
20
        // per second. In normal Opencaching.de operation, we expect just 1 changed
21
        // text item per cronjob run.
22
        //
23
        // Let's allow 20 per run. This will yield a timely indexing even in peak
24
        // activity situations, and still limit the cronjob runtime to a few seconds.
25
26
        // If there is some very huge batch outstanding, or for some special index
27
        // rebuild, we will leave it up to fill_search_index.php. This avoids
28
        // duplicate word counting when both run concurrently (though the word
29
        // counts are uncritical an so far not used at all).
30
31
        if (sql_value('SELECT COUNT(*) FROM `search_index_times`', 0) < 2000) {
32
            ftsearch_refresh(20);
33
        }
34
    }
35
}
36