Commit bda1a6f2 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

Fixed wrong suggestions caused by versions of subsets/datasets

fixed incorrect count value at overview page
parent 0a6a627f
......@@ -70,6 +70,9 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> imple
public Set<String> rights;
/** Is current version */
public Boolean current;
/**
* Builds the query.
*
......@@ -103,7 +106,6 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> imple
if (crops != null && !crops.isEmpty()) {
and.and(dataset.crops.any().in(crops));
}
if (locations != null) {
and.and(locations.buildQuery(dataset.locations.any()));
}
......@@ -111,7 +113,9 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> imple
if (CollectionUtils.isNotEmpty(rights)) {
and.and(dataset.rights.in(rights));
}
if (current != null) {
and.and(dataset.current.eq(current));
}
// if (StringUtils.isNotBlank(_text)) {
// /*@formatter:off*/
// and.andAnyOf(
......
......@@ -555,7 +555,7 @@ public class DatasetServiceImpl implements DatasetService {
} catch (NoSuchFieldException | IllegalAccessException e) {
LOG.error("Error while clearing filter: ", e.getMessage());
}
suggestionFilter.current = true;
ElasticsearchService.TermResult suggestion = elasticsearchService.termStatisticsAuto(Dataset.class, suggestionFilter, 100, suggestionKey);
suggestionRes.put(suggestionKey, suggestion);
}
......
......@@ -311,6 +311,7 @@ public class DatasetController extends ApiBaseController {
DatasetFilter overviewFilter = filter.copy(DatasetFilter.class);
overviewFilter.state = Sets.newHashSet(PublishState.PUBLISHED);
overviewFilter.current = true;
Map<String, TermResult> overview = elasticsearchService.termStatisticsAuto(Dataset.class, overviewFilter, 10, terms.toArray(new String[] {}));
long datasetCount = datasetService.countDatasets(overviewFilter);
......
......@@ -63,6 +63,9 @@ public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> implemen
public Set<String> crops;
/** Is current version */
public Boolean current;
/**
* Builds the query.
*
......@@ -96,6 +99,9 @@ public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> implemen
if (crops != null && !crops.isEmpty()) {
and.and(subset.crops.any().in(crops));
}
if (current != null) {
and.and(subset.current.eq(current));
}
return and;
}
......
......@@ -355,6 +355,7 @@ public class SubsetServiceImpl implements SubsetService {
} catch (NoSuchFieldException | IllegalAccessException e) {
LOG.error("Error while clearing filter: ", e.getMessage());
}
suggestionFilter.current = true;
ElasticsearchService.TermResult suggestion = elasticsearchService.termStatisticsAuto(Subset.class, suggestionFilter, 100, suggestionKey);
suggestionRes.put(suggestionKey, suggestion);
......@@ -776,7 +777,7 @@ public class SubsetServiceImpl implements SubsetService {
*
* @param target the target
* @param accessionRefs the subset accessionRefs
* @return
* @return
*/
private Subset copyAccessionRefs(final Subset target, final List<SubsetAccessionRef> accessionRefs) {
if (accessionRefs == null || accessionRefs.size() == 0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment