javascript embedding support
[phorkie.git] / scripts / index.php
1 <?php
2 //index repositories in elasticsearch
3
4 namespace phorkie;
5 require_once __DIR__ . '/../src/phorkie/autoload.php';
6 require_once __DIR__ . '/../data/config.default.php';
7 if (file_exists(__DIR__ . '/../data/config.php')) {
8     require_once __DIR__ . '/../data/config.php';
9 }
10 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
11     SetupCheck::run();
12 }
13
14
15 $db = new Database();
16
17 if ($db->prefix == '\phorkie\Database_Adapter_Null') {
18     echo "Error: No search adapter configured.\n";
19     exit(1);
20 }
21
22 $idx = $db->getIndexer();
23
24 //create mapping
25 echo "Index reset\n";
26 $db->getSetup()->reset();
27
28
29 $rs = new Repositories();
30 list($repos, $count) = $rs->getList(0, 10000);
31 foreach ($repos as $repo) {
32     echo 'Indexing ' . $repo->id . "\n";
33     $commits = $repo->getHistory();
34     $first = count($commits)-1;
35     $idx->addRepo($repo, $commits[$first]->committerTime, $commits[0]->committerTime);
36 }
37 ?>