Commit d9b5fe64 authored by Liang Ding's avatar Liang Ding

#12633

parent a90fc29d
......@@ -409,8 +409,7 @@ public class ArticleProcessor {
}
final List<JSONObject> articles = (List<JSONObject>) tagArticleResult.opt(Keys.RESULTS);
final int tagArticleCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
final int pageCount = (int) Math.ceil((double) tagArticleCount / (double) pageSize);
final int pageCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
dataModelService.setArticlesExProperties(context, articles, preference);
final JSONObject result = new JSONObject();
......
......@@ -141,12 +141,8 @@ public class TagProcessor {
final List<JSONObject> articles = (List<JSONObject>) tagArticleResult.opt(Keys.RESULTS);
dataModelService.setArticlesExProperties(context, articles, preference);
final int tagArticleCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
final int pageCount = (int) Math.ceil((double) tagArticleCount / (double) pageSize);
LOGGER.log(Level.TRACE, "Paginate tag-articles [currentPageNum={0}, pageSize={1}, pageCount={2}, windowSize={3}]",
currentPageNum, pageSize, pageCount, windowSize);
final int pageCount = tagArticleResult.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize);
LOGGER.log(Level.TRACE, "tag-articles [pageNums={0}]", pageNums);
fillPagination(dataModel, pageCount, currentPageNum, articles, pageNums);
dataModel.put(Common.PATH, "/tags/" + URLs.encode(tagTitle));
dataModel.put(Keys.OBJECT_ID, tagId);
......
......@@ -76,7 +76,7 @@ public class TagConsole {
* {
* "sc": boolean,
* "tags": [
* {"tagTitle": "", tagReferenceCount": int, ....},
* {"tagTitle": "", ....},
* ....
* ]
* }
......@@ -110,7 +110,7 @@ public class TagConsole {
* {
* "sc": boolean,
* "unusedTags": [
* {"tagTitle": "", tagReferenceCount": int, ....},
* {"tagTitle": "", ....},
* ....
* ]
* }
......
......@@ -93,8 +93,7 @@ public class ArchiveDateQueryService {
* "archiveDate": {
* "oId": "",
* "archiveTime": "",
* "archiveDatePublishedArticleCount": int,
* "archiveDateArticleCount": int
* "archiveDatePublishedArticleCount": int
* }
* }
* </pre>, returns {@code null} if not found
......
......@@ -630,6 +630,7 @@ public class ArticleQueryService {
if (0 == tagArticleRelations.length()) {
return null;
}
final JSONObject pagination = result.optJSONObject(Pagination.PAGINATION);
final Set<String> articleIds = new HashSet<>();
for (int i = 0; i < tagArticleRelations.length(); i++) {
......@@ -656,7 +657,7 @@ public class ArticleQueryService {
retArticles.add(article);
}
final JSONObject ret = new JSONObject();
ret.put(Pagination.PAGINATION, result.optJSONObject(Pagination.PAGINATION));
ret.put(Pagination.PAGINATION, pagination);
ret.put(Keys.RESULTS, (Object) retArticles);
return ret;
......
......@@ -77,7 +77,6 @@ public class TagQueryService {
* "tag": {
* "oId": "",
* "tagTitle": "",
* "tagReferenceCount": int,
* "tagPublishedRefCount": int
* }
* }
......@@ -86,15 +85,13 @@ public class TagQueryService {
*/
public JSONObject getTagByTitle(final String tagTitle) throws ServiceException {
try {
final JSONObject ret = new JSONObject();
final JSONObject tag = tagRepository.getByTitle(tagTitle);
if (null == tag) {
return null;
}
final JSONObject ret = new JSONObject();
ret.put(Tag.TAG, tag);
LOGGER.log(Level.DEBUG, "Got an tag[title={0}]", tagTitle);
return ret;
} catch (final RepositoryException e) {
......@@ -123,7 +120,7 @@ public class TagQueryService {
*
* @return for example, <pre>
* [
* {"tagTitle": "", "tagReferenceCount": int, ....},
* {"tagTitle": "", ....},
* ....
* ]
* </pre>, returns an empty list if not found
......
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