Commit 9ccf83a1 authored by Liang Ding's avatar Liang Ding

🎨 #12412

parent b6ca6eea
...@@ -53,7 +53,7 @@ import static org.b3log.solo.model.Article.*; ...@@ -53,7 +53,7 @@ import static org.b3log.solo.model.Article.*;
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a> * @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @author <a href="http://zephyr.b3log.org">Zephyr</a> * @author <a href="http://zephyr.b3log.org">Zephyr</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.3.2.1, May 17, 2018 * @version 1.3.2.2, May 17, 2018
* @since 0.3.5 * @since 0.3.5
*/ */
@Service @Service
...@@ -616,17 +616,9 @@ public class ArticleQueryService { ...@@ -616,17 +616,9 @@ public class ArticleQueryService {
query.addSort(ARTICLE_CREATE_DATE, SortDirection.DESCENDING); query.addSort(ARTICLE_CREATE_DATE, SortDirection.DESCENDING);
} }
int articleCount = statisticQueryService.getBlogArticleCount();
final String keyword = requestJSONObject.optString(Common.KEYWORD); final String keyword = requestJSONObject.optString(Common.KEYWORD);
if (StringUtils.isBlank(keyword)) { if (StringUtils.isBlank(keyword)) {
query.setFilter(new PropertyFilter(ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, articleIsPublished)); query.setFilter(new PropertyFilter(ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, articleIsPublished));
if (!articleIsPublished) {
articleCount -= statisticQueryService.getPublishedBlogArticleCount();
} else {
articleCount = statisticQueryService.getPublishedBlogArticleCount();
}
} else { } else {
query.setFilter(CompositeFilterOperator.and( query.setFilter(CompositeFilterOperator.and(
new PropertyFilter(ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, articleIsPublished), new PropertyFilter(ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, articleIsPublished),
...@@ -635,15 +627,11 @@ public class ArticleQueryService { ...@@ -635,15 +627,11 @@ public class ArticleQueryService {
new PropertyFilter(ARTICLE_TAGS_REF, FilterOperator.LIKE, "%" + keyword + "%") new PropertyFilter(ARTICLE_TAGS_REF, FilterOperator.LIKE, "%" + keyword + "%")
) )
)); ));
articleCount = pageSize;
} }
final int pageCount = (int) Math.ceil((double) articleCount / (double) pageSize);
query.setPageCount(pageCount);
final JSONObject result = articleRepository.get(query); final JSONObject result = articleRepository.get(query);
final int pageCount = result.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
final JSONObject pagination = new JSONObject(); final JSONObject pagination = new JSONObject();
ret.put(Pagination.PAGINATION, pagination); ret.put(Pagination.PAGINATION, pagination);
final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize); final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize);
......
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