Use commit timestamps for ElasticSearch and sort on last commit time.
[phorkie.git] / scripts / index.php
index 5afbee090d70fad2d35af5a1016444bf6332aa16..5da912e2aa9750faceaa004c20841cb5847feceb 100644 (file)
@@ -28,19 +28,17 @@ if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
 $db = new Database();
 $idx = $db->getIndexer();
 
-//cleanup
-echo "Deleting all index data\n";
-$idx->deleteAllRepos();
-
 //create mapping
-echo "Index setup\n";
-$db->getSetup()->setup();
+echo "Index reset\n";
+$db->getSetup()->reset();
 
 
 $rs = new Repositories();
 list($repos, $count) = $rs->getList(0, 10000);
 foreach ($repos as $repo) {
     echo 'Indexing ' . $repo->id . "\n";
-    $idx->addRepo($repo, filectime($repo->gitDir));
+    $commits = $repo->getHistory();
+    $first = count($commits)-1;
+    $idx->addRepo($repo, $commits[$first]->committerTime, $commits[0]->committerTime);
 }
 ?>