Commit 5ec3d5c5 authored by Maxym Borodenko's avatar Maxym Borodenko

Fixed bug: Inconsistent API response

parent 36cffdf9
...@@ -305,12 +305,13 @@ public class DescriptorServiceImpl implements DescriptorService { ...@@ -305,12 +305,13 @@ public class DescriptorServiceImpl implements DescriptorService {
@Override @Override
public Page<Descriptor> listDescriptors(final DescriptorFilter descriptorFilter, final Pageable page) { public Page<Descriptor> listDescriptors(final DescriptorFilter descriptorFilter, final Pageable page) {
Pageable markdownSortPageRequest = JPAUtils.toMarkdownSort(page, "title"); Pageable markdownSortPageRequest = JPAUtils.toMarkdownSort(page, "title");
Page<Descriptor> res;
if (descriptorFilter.isFulltextQuery()) { if (descriptorFilter.isFulltextQuery()) {
return elasticsearchService.findAll(Descriptor.class, descriptorFilter, descriptorFilter._text, markdownSortPageRequest); res = elasticsearchService.findAll(Descriptor.class, descriptorFilter, descriptorFilter._text, markdownSortPageRequest);
} else { } else {
return descriptorRepository.findAll(new BooleanBuilder().and(descriptorFilter.buildPredicate()).and(QDescriptor.descriptor.state.in(PublishState.PUBLISHED)), markdownSortPageRequest); res = descriptorRepository.findAll(new BooleanBuilder().and(descriptorFilter.buildPredicate()).and(QDescriptor.descriptor.state.in(PublishState.PUBLISHED)), markdownSortPageRequest);
} }
return new PageImpl<>(res.getContent(), page, res.getTotalElements());
} }
/** /**
......
Markdown is supported
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