Search in sources :

Example 1 with IndexerSearchEntity

use of org.nzbhydra.indexers.IndexerSearchEntity 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);
}
Also used : IndexerSearchEntity(org.nzbhydra.indexers.IndexerSearchEntity) SearchEntity(org.nzbhydra.searching.SearchEntity) IndexerSearchEntity(org.nzbhydra.indexers.IndexerSearchEntity)

Example 2 with IndexerSearchEntity

use of org.nzbhydra.indexers.IndexerSearchEntity in project nzbhydra2 by theotherp.

the class Searcher method createOrUpdateIndexerSearchEntity.

private void createOrUpdateIndexerSearchEntity(SearchCacheEntry searchCacheEntry, Map<Indexer, List<IndexerSearchResult>> indexersToSearchAndTheirResults, DuplicateDetectionResult duplicateDetectionResult) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    int countEntities = 0;
    for (IndexerSearchResult indexerSearchResult : indexersToSearchAndTheirResults.values().stream().flatMap(List::stream).collect(Collectors.toList())) {
        IndexerSearchEntity entity = searchCacheEntry.getIndexerSearchEntitiesByIndexer().get(indexerSearchResult.getIndexer().getIndexerEntity());
        if (entity == null) {
            entity = new IndexerSearchEntity();
            entity.setIndexerEntity(indexerSearchResult.getIndexer().getIndexerEntity());
            entity.setSearchEntity(searchCacheEntry.getSearchEntity());
            entity.setResultsCount(indexerSearchResult.getTotalResults());
            entity.setSuccessful(indexerSearchResult.isWasSuccessful());
        }
        entity.setProcessedResults(indexerSearchResult.getSearchResultItems().size());
        entity.setUniqueResults(duplicateDetectionResult.getUniqueResultsPerIndexer().count(indexerSearchResult.getIndexer()));
        entity = indexerSearchRepository.save(entity);
        searchCacheEntry.getIndexerSearchEntitiesByIndexer().put(indexerSearchResult.getIndexer().getIndexerEntity(), entity);
        countEntities++;
    }
    logger.debug(LoggingMarkers.PERFORMANCE, "Saving {} indexer search entities took {}ms", countEntities, stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
Also used : IndexerSearchEntity(org.nzbhydra.indexers.IndexerSearchEntity) Stopwatch(com.google.common.base.Stopwatch)

Aggregations

IndexerSearchEntity (org.nzbhydra.indexers.IndexerSearchEntity)2 Stopwatch (com.google.common.base.Stopwatch)1 SearchEntity (org.nzbhydra.searching.SearchEntity)1