use of com.searchcode.app.jobs.repository.IndexFileRepoJob in project searchcode-server by boyter.
the class AdminRouteService method checkIndexStatus.
public String checkIndexStatus(Request request, Response response) {
if (request.queryParams().contains("reponame")) {
String reponame = request.queryParams("reponame");
String reposLocation = Properties.getProperties().getProperty(Values.REPOSITORYLOCATION, Values.DEFAULTREPOSITORYLOCATION);
IndexBaseRepoJob indexBaseRepoJob = new IndexFileRepoJob();
RepoResult repoResult = Singleton.getRepo().getRepoByName(reponame);
String indexStatus = Values.EMPTYSTRING;
if (repoResult != null) {
indexStatus = repoResult.getData().indexStatus;
}
if (indexBaseRepoJob.checkIndexSucess(reposLocation + "/" + reponame) || "success".equals(indexStatus)) {
return "Indexed ✓";
}
if ("indexing".equals(indexStatus)) {
return "Indexing...";
}
}
return Values.EMPTYSTRING;
}
use of com.searchcode.app.jobs.repository.IndexFileRepoJob in project searchcode-server by boyter.
the class IndexFileRepoJobTest method testGetCodeOwner.
public void testGetCodeOwner() {
IndexFileRepoJob fileRepoJob = new IndexFileRepoJob();
String codeOwner = fileRepoJob.getCodeOwner(null, null, null, null, null);
assertThat(codeOwner).isEqualTo("File System");
}
use of com.searchcode.app.jobs.repository.IndexFileRepoJob in project searchcode-server by boyter.
the class IndexFileRepoJobTest method testGetFileLocationFilename.
public void testGetFileLocationFilename() {
IndexFileRepoJob fileRepoJob = new IndexFileRepoJob();
fileRepoJob.repoName = "repo";
String fileLocationFilename = fileRepoJob.getFileLocationFilename(".git/filename", "./repo/");
assertThat(fileLocationFilename).isEqualTo("repo.git/filename");
fileLocationFilename = fileRepoJob.getFileLocationFilename("./repo/.git/filename", "./repo/");
assertThat(fileLocationFilename).isEqualTo("repo.git/filename");
}
use of com.searchcode.app.jobs.repository.IndexFileRepoJob in project searchcode-server by boyter.
the class EndToEndITCase method testEndToEndFilePath.
public void testEndToEndFilePath() throws IOException {
CodeSearcher cs = new CodeSearcher();
File directoryWithFiles = TestHelpers.createDirectoryWithFiles("EndToEndFileTest");
IndexFileRepoJob indexFileRepoJob = new IndexFileRepoJob();
// Index created files
indexFileRepoJob.indexDocsByPath(Paths.get(directoryWithFiles.toString()), "ENDTOENDTEST", "", directoryWithFiles.toString(), false);
SearchResult searchResult = cs.search("endtoendtestfile", 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(3);
CodeResult codeResult1 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile1.php")).findFirst().get();
CodeResult codeResult2 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile2.py")).findFirst().get();
CodeResult codeResult3 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile3.java")).findFirst().get();
assertThat(codeResult1.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile1");
assertThat(codeResult2.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile2");
assertThat(codeResult3.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile3");
// Delete a single file
String codeId = searchResult.getCodeResultList().get(0).getCodeId();
Singleton.getCodeIndexer().deleteByCodeId(codeId);
searchResult = cs.search("endtoendtestfile".toLowerCase(), 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(2);
codeResult1 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile2.py")).findFirst().get();
codeResult2 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile3.java")).findFirst().get();
assertThat(codeResult1.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile2");
assertThat(codeResult2.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile3");
// Delete file from disk then index to ensure it is removed from the index
File toDelete = new File(directoryWithFiles.toString() + "/EndToEndTestFile2.py");
toDelete.delete();
indexFileRepoJob.indexDocsByPath(Paths.get(directoryWithFiles.toString()), "ENDTOENDTEST", "", directoryWithFiles.toString(), true);
searchResult = cs.search("endtoendtestfile", 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(2);
codeResult1 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile1.php")).findFirst().get();
codeResult2 = searchResult.getCodeResultList().stream().filter(x -> x.getFileName().equals("EndToEndTestFile3.java")).findFirst().get();
assertThat(codeResult1.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile1");
assertThat(codeResult2.getCode().get(0)).isEqualTo("EndToEndTestFile EndToEndTestFile3");
// Delete everything
Singleton.getCodeIndexer().deleteByReponame("ENDTOENDTEST");
searchResult = cs.search("endtoendtestfile".toLowerCase(), 0);
assertThat(searchResult.getCodeResultList().size()).isEqualTo(0);
}
Aggregations