fix rewrite map loading
[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 $idx = $db->getIndexer();
17
18 //create mapping
19 echo "Index reset\n";
20 $db->getSetup()->reset();
21
22
23 $rs = new Repositories();
24 list($repos, $count) = $rs->getList(0, 10000);
25 foreach ($repos as $repo) {
26     echo 'Indexing ' . $repo->id . "\n";
27     $commits = $repo->getHistory();
28     $first = count($commits)-1;
29     $idx->addRepo($repo, $commits[$first]->committerTime, $commits[0]->committerTime);
30 }
31 ?>