use of org.nzbhydra.searching.SearchEntity in project nzbhydra2 by theotherp.
the class History method getSearchDetails.
public SearchDetails getSearchDetails(int searchId) {
SearchEntity search = searchRepository.findOne(searchId);
Collection<IndexerSearchEntity> entities = indexerSearchRepository.findBySearchEntity(search);
List<IndexerSearchTO> details = new ArrayList<>();
for (IndexerSearchEntity entity : entities) {
details.add(new IndexerSearchTO(entity.getIndexerEntity().getName(), entity.getSuccessful(), entity.getResultsCount()));
}
return new SearchDetails(search.getUsername(), search.getIp(), search.getUserAgent(), search.getSource().name(), details);
}
use of org.nzbhydra.searching.SearchEntity in project nzbhydra2 by theotherp.
the class SearchingResultsUiTest method testRepeatSearch.
@Test
public void testRepeatSearch() throws Exception {
prepareFiveResultsFromTwoIndexers();
SearchEntity entity = new SearchEntity();
entity.setQuery("uitest");
entity.setCategoryName("All");
entity.setSource(SearchSource.INTERNAL);
searchRepository.save(entity);
webDriver.get(url);
WebDriverWait wait = new WebDriverWait(webDriver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("history-dropdown-button")));
SearchPO searchPO = factory.createPage(SearchPO.class);
searchPO.historyDropdownButton().click();
List<org.popper.fw.element.ILink> historyEntries = searchPO.searchHistoryEntries();
assertThat(historyEntries.size()).isEqualTo(1);
assertThat(historyEntries.get(0).text()).isEqualTo("Category: All, Query: uitest");
historyEntries.get(0).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("search-results-table")));
SearchResultsPO searchResultsPage = factory.createPage(SearchResultsPO.class);
// Only indexer1 was preselected and that's the one used for the repeated search
assertThat(searchResultsPage.searchResultRows().size()).isEqualTo(3);
assertThat(searchResultsPage.titles()).containsExactlyInAnyOrder("indexer1-result1", "indexer1-result2", "indexer1-result3");
}
use of org.nzbhydra.searching.SearchEntity in project nzbhydra2 by theotherp.
the class ThreadedTest method executeParallelSaves.
@Test
public void executeParallelSaves() throws Exception {
ExecutorService pool = Executors.newFixedThreadPool(50);
for (int i = 0; i < 50; i++) {
pool.execute(() -> {
Stopwatch stopwatch = Stopwatch.createStarted();
for (int i1 = 0; i1 < 100; i1++) {
SearchEntity searchEntity = new SearchEntity();
searchEntity.setQuery("query");
searchEntity.setSearchType(SearchType.SEARCH);
searchEntity.setEpisode("123");
searchEntity.setSeason(234);
searchRepository.save(searchEntity);
}
System.out.println("Saving 100 took " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
});
}
pool.awaitTermination(10, TimeUnit.SECONDS);
}
use of org.nzbhydra.searching.SearchEntity in project nzbhydra2 by theotherp.
the class SqliteMigrationTest method shouldMigrateSearches.
// TODO tests are still for old json based sqlite migration, need to be adapted to actual sqlite access
@Test
@Ignore
public void shouldMigrateSearches() throws Exception {
String searchesJson = Resources.toString(Resources.getResource(SqliteMigrationTest.class, "searches"), Charsets.UTF_8);
List<Map<String, Object>> oldSearches = testee.objectMapper.readValue(searchesJson, testee.listOfMapsTypeReference);
Map<Integer, SearchEntity> searchEntities = testee.migrateSearches();
assertThat(searchEntities.size(), is(4));
SearchEntity entityTv = searchEntities.get(3);
assertThat(entityTv.getAuthor(), is(nullValue()));
assertThat(entityTv.getUsername(), is(nullValue()));
assertThat(entityTv.getSeason(), is(1));
assertThat(entityTv.getEpisode(), is(2));
assertThat(entityTv.getIdentifiers().size(), is(1));
IdentifierKeyValuePair keyValuePair = entityTv.getIdentifiers().iterator().next();
assertThat(keyValuePair.getIdentifierKey(), is(IdType.TVDB.name()));
assertThat(keyValuePair.getIdentifierValue(), is("456"));
assertThat(entityTv.getQuery(), is(nullValue()));
assertThat(entityTv.getSearchType(), is(SearchType.TVSEARCH));
assertThat(entityTv.getCategoryName(), is("TV"));
SearchEntity entityAll = searchEntities.get(2);
assertThat(entityAll.getAuthor(), is(nullValue()));
assertThat(entityAll.getUsername(), is(nullValue()));
assertThat(entityAll.getEpisode(), is(nullValue()));
assertThat(entityAll.getSeason(), is(nullValue()));
assertThat(entityAll.getIdentifiers(), is(empty()));
assertThat(entityAll.getQuery(), is("aquery"));
assertThat(entityAll.getSearchType(), is(SearchType.SEARCH));
assertThat(entityAll.getCategoryName(), is("All"));
}
use of org.nzbhydra.searching.SearchEntity in project nzbhydra2 by theotherp.
the class History method getHistoryForSearching.
public List<SearchEntity> getHistoryForSearching() {
String currentUserName = SessionStorage.username.get();
Page<SearchEntity> history = currentUserName == null ? searchRepository.findForUserSearchHistory(new PageRequest(0, 100)) : searchRepository.findForUserSearchHistory(currentUserName, new PageRequest(0, 100));
List<SearchEntity> entities = new ArrayList<>();
Set<Integer> contained = new HashSet<>();
for (SearchEntity searchEntity : history.getContent()) {
int hash = searchEntity.getComparingHash();
if (contained.contains(hash)) {
continue;
}
contained.add(hash);
entities.add(searchEntity);
if (entities.size() == 15) {
break;
}
}
return entities;
}
Aggregations